This is probably going to be very obvious, but here goes. I have two ViewControllers, one that shows the details of a person with a [+] button that opens up another ViewController that manages the edits of the Person. When the person about to be deleted, an alert is presented and if OK is selected, the edit view should disappear and the DetailView should also disappear/transition back to the PersonsListView (not shown in code below).
这可能会非常明显,但这里也是如此。我有两个ViewControllers,一个用[+]按钮显示一个人的详细信息,打开另一个ViewController来管理Person的编辑。当要删除的人员时,会显示警报,如果选择了“确定”,则编辑视图应该消失,并且DetailView也应该消失/转换回PersonsListView(下面的代码中未显示)。
I can get the EditView to dismiss, but I can't get the DetailView to dismiss as well.
我可以让EditView解散,但我也无法解除DetailView。
Any help is appreciated.
任何帮助表示赞赏。
The two ViewControllers:
两个ViewControllers:
@implementation PersonDetailViewController
...
- (void)editPerson
{
PersonDetailEditViewController *editView = [[PersonDetailEditViewController alloc] initWithTenant:self.person];
[editView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:editView];
[self presentModalViewController:navController animated:YES];
}
...
@end
and
@implementation PersonDetailEditViewController
...
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
[Person deletePerson:self.person];
NSError *error;
[self.person.managedObjectContext save:&error];
[[self navigationController] dismissModalViewControllerAnimated:YES];
// *** HERE I ALSO WANT TO DISMISS THE DETAILVIEW ***
}
}
...
@end
1 个解决方案
#1
1
Assuming that PersonDetailViewController is presented in a navigation controller you should be able to do what you want by adding the following line:
假设PersonDetailViewController出现在导航控制器中,您应该可以通过添加以下行来执行您想要的操作:
[self.navigationController popViewControllerAnimated:YES];
#1
1
Assuming that PersonDetailViewController is presented in a navigation controller you should be able to do what you want by adding the following line:
假设PersonDetailViewController出现在导航控制器中,您应该可以通过添加以下行来执行您想要的操作:
[self.navigationController popViewControllerAnimated:YES];