如何从 NavigationController 堆栈将消息发送回 UIScrollView?
我的视图控制器的结构如下:
> UIWindow
> - RootViewController with UIScrollView (2 pages, pagingEnabled)
> -- UINavigationController (in the first page of the scrolling view)
> --- HomePageViewController (plus other ViewControllers pushed on the stack)
> -- MinutiaViewController (second page)
UIScrollView 将 UInavigationController 作为子视图 [scrollView addSubview:navController.view];
在我的场景中我想:
- 将新视图推送到 UINavigationViewController 后禁用 UIScrollView 滚动 (scrollEnable=NO)
- 一旦弹出新视图并且 UINavigationController 再次显示其根,再次启用 UIScrollView (scrollEnable=YES) (HomePageViewController)
我想出了如何在推送新视图时禁用scrollView滚动。
但是无法弄清楚当新视图从堆栈中弹出时如何启用scrollView滚动。
到目前为止我尝试过
1 触发viewWillAppear;视图将消失;手动并发送 从 HomePageViewController 的 viewWillAppear 发送到 UIScrollView 的消息 例如
[self.navigationController.parentViewController performSelector:@selector(enableScrollAgain)];
2 将 RootViewController 指定为 UINavigationController 委托来处理其 活动
到目前为止似乎都不起作用。感谢所有建议!
My view controllers are structured like this:
> UIWindow
> - RootViewController with UIScrollView (2 pages, pagingEnabled)
> -- UINavigationController (in the first page of the scrolling view)
> --- HomePageViewController (plus other ViewControllers pushed on the stack)
> -- MinutiaViewController (second page)
UIScrollView holds the UInavigationController as a subview[scrollView addSubview:navController.view];
In my scenario I want to:
- disable UIScrollView scrolling (scrollEnable=NO) once a new view is pushed onto the UINavigationViewController
- enable UIScrollView again (scrollEnable=YES) once the new view is popped and the UINavigationController shows its root again
(HomePageViewController)
I figured out how to disable the scrollView scrolling when pushing a new view.
But cannot figure out how to enable the scrollView scrolling when the new view pops off the stack.
So far I tried
1 triggering viewWillAppear; viewWillDisappear; manually and sending a
message to UIScrollView from HomePageViewController's viewWillAppear
e.g.
[self.navigationController.parentViewController performSelector:@selector(enableScrollAgain)];
2 designated the RootViewController as a UINavigationController delegate to handle its
events
None seems to work so far. All advice appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过使用通知吗?您可以添加 RootView 来观察导航控制器的通知,当您收到该通知时,您可以禁用滚动。查看通知中心。
希望这有帮助
Have you tried using Notifications ? You could add the RootView to observe a notification form the navigation controller, when you get that notification you can disable scrolling. Look into NotificationCenter.
Hope this helps