我試圖讓我的UIAlert在單擊按鈕時執行兩個不同的操作。當用戶點擊重新啓動時,遊戲重新開始,當主菜單被點擊時,遊戲應該進入主菜單。重置按鈕工作正常,但IBAction不斷給我提供有關切換視圖的錯誤。將IBAction添加到UIAlert
// called when the player touches the "Reset Game" button
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
[self resetGame];
}
else
{
- (IBAction)showFlip:(id)sender {
Menu *menuView = [[[menu alloc] init] autorelease];
[gameView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:menuView animated:YES];
}
}
}
重置工作正常,但我得到IBAction兩個錯誤。 'showFlip'未聲明(首次在此函數中使用)和期望';'之前':'令牌。不明白爲什麼會這樣說,因爲當我在alertview之外發布IBAction時,它工作正常。 任何幫助,將不勝感激,在此先感謝
謝謝!這樣做的竅門,因爲你可能會告訴我這個東西很新。 – MacN00b
@ MacN00b樂於助人。 – PengOne