我有一些代碼,當用戶點擊遊戲結束時,它會提示他們,如果想再次發揮:UIAlertView中和detemining點擊什麼
-(void)showAlert
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" B U S T E D ! "
message:@"Sorry, you busted!\n\nWant to try your luck 1 More Time! ?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"New Game", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
//here is where we can close it
}
if (buttonIndex == 1)
{
[self createNewGame];
}
}
現在我想也做一次檢查時用戶首先啓動應用程序以查看是否存在先前的遊戲文件,如果是,詢問他們是否想要繼續。我知道我可以通過:
-(void)priorGameExists
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" Previous Game Exists ! "
message:@"A previous game currently exists. Would you like to resume that game?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Resumse", nil];
[alert show];
[alert release];
}
但是,我該如何去一個新的「自定義」clickedButtonAtIndex?我是否認爲它與設置不同的代表有關?如果是這樣,我該怎麼做?
的答案似乎集中在兩個UIAlertViews,這是解決你的問題的一種方法之間的區別,所以我投票關閉此爲重複。 – 2010-02-26 16:28:16