我正在使用mapkit视图,我在注释上添加了一个按钮,如下所示:
UIButton *bt = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[bt setFrame:CGRectMake(0, 0, 30, 30)];
annView.rightCalloutAccessoryView = bt;
我想在触摸该按钮时转到另一个视图(例如expleViewController),我习惯于使用IBAction方法执行此操作并使用Interface Builder将其与按钮链接,但此按钮是手动创建的,那我该如何链接呢?
答案 0 :(得分:1)
[bt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
- (void)buttonPressed:(UIButton *)b
{
// do whatever you want ;)
}