如何返回到前一个视图控制器?
问题描述:
当用户从UIAlertController弹出窗口中单击“确定”按钮时,它将返回到先前的视图控制器。我坚持如何。下面是我的代码。如何返回到前一个视图控制器?
if (jsonData == nil){
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error!" message:@"This Git repository is empty" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}
答
试试这个 -
if (jsonData == nil){
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error!" message:@"This Git repository is empty" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
// Ok action example
[self.navigationController popViewControllerAnimated:YES];
}];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}
Awesome..its工作..日Thnx sir..almost2小时我在找这个答案! –
很高兴为您效劳。 –
完成upvote @Dipankar Das :) –