我搜索了一些方法,一旦点击警报视图上的按钮,我就可以转到新页面。我必须使用prepareForSegue方法吗?或者有更简单的方法吗?
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex ==0){
//code goes here
}
if(buttonIndex ==1){
NSString *username = [[alertView textFieldAtIndex:0] text];
NSString *password = [[alertView textFieldAtIndex:1] text];
NSLog(@"Username:%@",username);
NSLog(@"Password:%@",password);
//Check if username and password tally if tally move on to Menu page
MainPageViewController *anotherController = [[MainPageViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
[self.navigationController pushViewController:anotherController animated:YES];
}
}
答案 0 :(得分:0)
您必须使用alertview委托方法 - alertView:clickedButtonAtIndex:
来了解单击了哪个按钮,您可以对其执行后续操作。