搜尋此網誌

顯示具有 alert 標籤的文章。 顯示所有文章
顯示具有 alert 標籤的文章。 顯示所有文章

2012年9月4日 星期二

如何判斷是哪個alert


方法一
@property (nonatomic, strong) UIAlertView *passwordAlert;
@property (nonatomic, strong) UIAlertView *warningAlert;

passwordAlert = [[UIAlertView alloc] initWithTitle:@"Password" message:@"Enter password" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Done", nil];
passwordAlert.alertViewStyle = UIAlertViewStyleSecureTextInput;
[passwordAlert show];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
   if (alertView == passwordAlert) {
      // handle anything for password button indexes here
   }
   if (alertView == warningAlert)_ {
      // handle anything for warning button indexes here
   }
}
方法二