Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我们如何通过示例在@selector中传递参数?_Iphone_Xcode - Fatal编程技术网

Iphone 我们如何通过示例在@selector中传递参数?

Iphone 我们如何通过示例在@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.

我们如何将@selector方法中的参数传递给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);
}
这里我想得到这个方法的标签值

请帮我解决这个问题

您应该使用

@selector(showRestaurant:)

选择器应该匹配方法签名,减去方法中变量的“内部名称”。

您应该使用

@selector(showRestaurant:)

选择器应该匹配方法签名,减去方法中变量的“内部名称”