所以這就是我所擁有的。我創建了一個按鈕並將其設置爲一個動作,但每次單擊該按鈕時它都會使程序崩潰。爲什麼我的按鈕不工作?提前致謝。編程添加按鈕不會工作
UIButton *currentGamesButton = [UIButton buttonWithType:UIButtonTypeCustom];
currentGamesButton.frame = CGRectMake(124,18,72,65);
[currentGamesButton addTarget:self
action:@selector(goToCurrentGamesViewController:)
forControlEvents:UIControlEventTouchDown];
UIImage *currentGamesPNG = [UIImage imageNamed:@"CurrentGamesHighlightedState.png"];
[currentGamesButton setBackgroundImage:currentGamesPNG forState:UIControlStateNormal];
[self.view addSubview:currentGamesButton];
我懷疑它沒有找到選擇器goToCurrentGamesViewController:你能顯示代碼這個方法,包括它的聲明? – 2012-04-18 19:01:41
在.h中:(IBAction)goToCurrentGamesViewController; – nfoggia 2012-04-18 19:13:04
.m(IBAction)goToCurrentGamesViewController { – nfoggia 2012-04-18 19:13:26