我的应用程序中有一个 uialertview,它有两个按钮,第一个是取消按钮,第二个是好的。当我按下“确定”按钮时,我想转到具有情节提要标识符“RootView”的视图控制器,但它不起作用。我把下面的代码放在 appdelegate.m 方法中。
- (void)showAlarm:(NSString *)text {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"show alarm"
message:text delegate:self
cancelButtonTitle:@"cancel"
otherButtonTitles:@"ok", nil];
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
NSLog(@"cancel");
}else if (buttonIndex == 1){
NSLog(@"ok");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];
[navigationController presentViewController:[storyboard instantiateViewControllerWithIdentifier:@"RootView"] animated:YES completion:nil];
}
}