Iphone 我们如何通过示例在@selector中传递参数?
我们如何将@selector方法中的参数传递给UIButtonIphone 我们如何通过示例在@selector中传递参数?,iphone,xcode,Iphone,Xcode,我们如何将@selector方法中的参数传递给UIButton -(void)loadView{ UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; btn1.tag=1; [btn1 addTarget:self action:@selector(showRestaurant:tag:) forControlEvents:UIControlEventTouchDown]; btn1.
-(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);
}
这里我想得到这个方法的标签值
请帮我解决这个问题 您应该使用
@selector(showRestaurant:)
及
选择器应该匹配方法签名,减去方法中变量的“内部名称”。您应该使用
@selector(showRestaurant:)
及
选择器应该匹配方法签名,减去方法中变量的“内部名称”