tags:

views:

30

answers:

1

How do we pass the arguments in @selector method for UIButton?

-(void)loadView{
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];  
    btn1.tag=1;
    [btn1 addTarget:self  action:@selector(showRestaurant:tag:) forControlEvents:UIControlEventTouchDown];
    btn1.frame = CGRectMake(2370.828125,1020.015625,35,34);
    [imageView addSubview:btn1];
}

-(void)showRestaurant:(NSInteger)tag{
    NSLog(@"x=%d",tag);
}

Here i want to get the tag value for this method showRestaurant.

Kindly help me regarding on this!

+1  A: 

You should use

@selector(showRestaurant:)

and

-(void)showRestaurant:(UIButton*)btn
{
    NSLog(@"tag=%d",btn.tag);
}

the selector should match the method signature, minus the "internal names" of the variables in the method.

mvds