[英]UIAlertView Button Action
如何在UIButton
點擊中使用兩個動作?我有一個UIAlertView顯示兩個按鈕。再次播放並退出。現在我想在這些按鈕的點擊事件中執行兩個方法。
UIAlertView已棄用。 您現在可以使用UIAlertController作為解釋在這里 。
你可以像這樣創建一個UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"reset", nil]; [alert show];
要處理AlertView按鈕單擊,您必須符合 UIAlertViewDelegate
協議。
@interface YourViewController:UIViewController<UIAlertViewDelegate>{ ....... ....... }
然后實現 UIAlertViewDelegate
協議方法,
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == [alertView cancelButtonIndex]){ //cancel clicked ...do your action }else{ //reset clicked } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.