0
我在方法中有2個alertView,我想檢查第二個alertView的按鈕索引。我該怎麼做?我想獲取else條件的buttonIndex。以下是我正在嘗試的代碼。要做到這一點檢查第二個UIAlertView的buttonIndex
-(IBAction)buttonClick{
NSString *connect = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.xyz.com"] encoding:NO error:nil];
if(connect == NULL) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"No Internet Connection" message:@"Please check your internet connection" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
} else {
UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:@"Upload to the server?" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"CANCEL",nil];
[alert1 show];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
My functionality
}
我會說這是「存儲alertViews的財產」,而不是「讓他們的全球」更好的建議。否則同意:) – JoeFryer