2012-08-06 53 views
-1

我工作的一個mapkit看法,我說在這樣的一個註解按鈕:上的一個按鈕添加一個動作沒有IBAction爲

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

annView.rightCalloutAccessoryView = bt; 

我想去另一個視圖(例如expleViewController)時觸摸那個按鈕,我習慣使用IBAction方法做它,並使用Interface Builder將它與按鈕鏈接起來,但是這個按鈕是手動創建的,所以我怎樣才能鏈接它?

+0

但是下次請努力閱讀官方文檔。 – 2012-08-06 12:15:23

回答

1
[bt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 

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