这将需要一些解释......所以我按顺序执行:
我有一个UserViewController作为弹出窗口加载:
UserViewController * userView = [[UserViewController alloc] initWithNibName:@" UserView"捆绑:[NSBundle mainBundle]]; [userView setUEmail:email]; [self presentPopupViewController:userView animationType:MJPopupViewAnimationSlideTopBottom];
然后我有另一个弹出窗口加载到这个弹出窗口:
放置* p = [placeArray objectAtIndex:indexPath.row];
DetailPlaceViewController *pvc = [[DetailPlaceViewController alloc] init];
[pvc setPlace:p];
NSLog(@"%@", p.PName);
[self presentPopupViewController:pvc animationType:MJPopupViewAnimationSlideTopBottom];
现在我有这样做的原因:AppDelegate有一个导航控制器,之前我加载了这样的UserView:
[self.navigationController presentViewController:userView animated:YES completion:nil];
但这意味着UserView会在iPhone上加载而不是在iPad上加载,原因有些奇怪。但当我将其切换到弹出视图时,它工作正常。
所以现在我在弹出窗口中加载UserView和DetailPlaceView ......但现在它在iPad上关闭但在iPhone上没有。
这是关闭详细信息视图的代码:
- (void) didTapBackButton:(id)sender {
NSLog(@"View Controller Number: %lu", (unsigned long)self.navigationController.viewControllers.count);
if(self.navigationController.viewControllers.count > 1) {
[self.navigationController popViewControllerAnimated:YES];
NSArray *stack = self.navigationController.viewControllers;
TipCollectionViewController *tipsVC = stack[stack.count-1];
[tipsVC.collectionView reloadData];
}
我知道有更好的办法处理这件事......但我应该做些什么呢?
更新
如果我将其切换回:
[self.navigationController pushViewController:userview animated:YES];
...对于iPhone上的UserView和:
[self.navigationController pushViewController:pvc animated:YES];
...对于之后加载的视图,然后UserView将加载...但是下一个viewcontroller(DetailPlaceViewController)不会加载。我认为这是我的主要问题。如果我可以加载它,我可能会在那时解雇第二个视图控制器。有什么想法吗?
答案 0 :(得分:0)
[self presentPopupViewController:pvc animationType:MJPopupViewAnimationSlideTopBottom];
如果你使用它,presentPopupViewController用于显示类似的模态视图,不能在没有任何自定义取消操作的情况下被解除。
要使用popOverViewController方法,请使用pushViewController。那么你可以通过这种方法解雇。
答案 1 :(得分:0)
最终,我所要做的就是切换:
[self.navigationController pushViewController:pvc animated:YES];
为:
[self presentViewController:pvc animated:YES];
它有效。它打开和关闭视图,一切正常。
点击某个项目后,我在DetailView上收到警告:
Presenting view controllers on detached view controllers is discouraged <UserViewController: 0x16e02020>
所以我会等几天才接受我的回答。否则,尽管有警告,它似乎仍然有效。