我有2节课。第一个是Label,另一个是LabelGestureRecognizer。在 LabelGestureRecognizer 中有一个名为 getName 的方法,我想通过 Label 类调用该方法。
下面是我的问题的一个简单示例。
我正在尝试调用方法 'getName',但我收到一条错误消息:“No visible @interface for 'LabelGestureRecognizer' 声明选择器 'getName:'”</p>
视图控制器.h:
@property (nonatomic, strong) UILabel *valueLabel;
视图控制器.m:
- (void)viewDidLoad
{
valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 366, 320, 50)];
valueLabel.textAlignment = UITextAlignmentCenter;
valueLabel.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:valueLabel];
}
- (void) wheelDidChangeValue:(NSString *) newValue {
self.valueLabel.text = newValue;
}
标签.h:
@protocol LabelDelegate <NSObject>
@required
-(void) wheelDidChangeValue:(NSString *) newValue;
@end
@class LabelGestureRecognizer;
标签手势识别器.m:
- (NSString *) getName:(int) position
{
NSString *resultat = @"";
switch (position) {
case 0:
resultat = @"Test 1";
break;
case 1:
resultat = @"Test 2";
break;
default:
break;
}
return resultat;
}
标签手势识别器.h:
@interface LabelGestureRecognizer : UIGestureRecognizer
{
NSDate *previous;
double current;
}
标签.m:
LabelGestureRecognizer *recognizer = [[LabelGestureRecognizer alloc] init];
[self.delegate wheelDidChangeValue:[self getName:0]];