user1546488
user1546488

Reputation: 61

Uilabel Tap gesture is crashing

I have a problem with tap gesture, I have a view controller and on top of the view controller am adding the UILABEL dynamically and adding tap gesture to the label. When Tap on the Uilabel it is crashing.

[ViewController singleTap:]: unrecognized selector sent to instance :- Crash report

Below is the piece of the code

- (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");
}

Upvotes: 0

Views: 175

Answers (1)

tia
tia

Reputation: 9698

It should be -(void) singleTap:(id)sender with uppercase T.

Upvotes: 1

Related Questions