Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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
Objective c 在没有iAction的按钮上添加操作_Objective C_Ios_Cocoa Touch_Uibutton - Fatal编程技术网

Objective c 在没有iAction的按钮上添加操作

Objective c 在没有iAction的按钮上添加操作,objective-c,ios,cocoa-touch,uibutton,Objective C,Ios,Cocoa Touch,Uibutton,我正在处理mapkit视图,我在注释上添加了一个按钮,如下所示: UIButton *bt = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [bt setFrame:CGRectMake(0, 0, 30, 30)]; annView.rightCalloutAccessoryView = bt; 我想在触摸该按钮时转到另一个视图(例如expleViewController),我习惯于使用iAction方法并使用Interf

我正在处理mapkit视图,我在注释上添加了一个按钮,如下所示:

UIButton *bt = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[bt setFrame:CGRectMake(0, 0, 30, 30)];

annView.rightCalloutAccessoryView = bt;

我想在触摸该按钮时转到另一个视图(例如expleViewController),我习惯于使用iAction方法并使用Interface Builder将其与按钮链接,但该按钮是手动创建的,因此如何链接它?

但下次请努力阅读官方文档。
[bt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

- (void)buttonPressed:(UIButton *)b
{
    // do whatever you want ;)
}