Uilabel Tap手势正在崩溃

时间:2013-06-16 17:01:47

标签: uilabel

我有点击手势的问题,我有一个视图控制器,在视图控制器的顶部动态添加UILABEL并向标签添加点击手势。当点击Uilabel时,它正在崩溃。

[ViewController singleTap:]:无法识别的选择器发送到实例: - 崩溃报告

以下是代码

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 150, 35)];
    label.userInteractionEnabled = YES;
    label.backgroundColor = [UIColor greenColor];
    label.text = @"label";
    label.textAlignment = NSTextAlignmentCenter;

    UITapGestureRecognizer * single = [[UITapGestureRecognizer alloc] initWithTarget:self     action:@selector(singleTap:)];
    [label addGestureRecognizer:single];
    single.numberOfTapsRequired = 1;
    [single release];

    [self.view addSubview:label];


}
-(void) singletap:(id)sender
{
    NSLog(@"single tap");
}

1 个答案:

答案 0 :(得分:1)

它应该是-(void) singleTap:(id)sender大写的T。