我提出了一些观点:
- 最上面的是一个 UITabBarController
- 第二个是带有推送 View 的 UINavigationController
- 第三个是模态框。
按下模态框中的关闭按钮后,我将尝试将所有内容恢复为默认状态并更改选项卡栏索引。
[self dismissModalViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:NO];
[self.tabBarController setSelectedIndex:3];
这会关闭模态视图,但不会执行任何其他操作。有什么想法可能是错的吗?我读到了一些关于可能的 ios 错误的内容,但我不知道如何解决它。
最佳答案
都不是UITabBarController
也不UINavigationController
是一个 View 。两者都是 UIViewController
的子类,并具有属性 NSArray *viewControllers
。
如果您有一个由 ActualViewController
控制的 actualView
,该 actualViewController
被推送到由 RootViewController
控制的 rootView
之上code> 是 navigationController
的 rootViewController
,并且您还有一个由 ModalViewController
控制的 modalView
,那么放
[self dismissModalViewControllerAnimated:YES];
在ModalViewController.m
中,并放入
[self.navigationController popViewControllerAnimated:NO];
在 ActualViewController.m
中(大概是从 modalView
被推送的地方),然后放置
[self.tabBarController setSelectedIndex:3];
在RootViewController.m
中(大概是从actualView
被推送的)。
如果modalViewController
从未添加到navigationController
,那么它就不知道navigationController
存在。
如果 actualViewController
从未添加到 tabBarController
,那么它就不知道 tabBarController
存在。
关于objective-c - ios sdk 一次只能更改一个 View 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6232077/