1.如何创建ViewController覆盖上一个ViewController
第二个ViewController不会完全覆盖第一个ViewController
场景类似,弹出一个弹窗,而这个弹窗实际上是一个ViewController而不是View
红色区域看类似一个UIView,实际上红色方块是在另一个ViewController上,而该ViewController的View的背景是透明的,因此可以看到前一个ViewController。
步骤:
设置第二个ViewController的View的背景为透明
-
设置第一个ViewController到第二个ViewController的Segue, Segue的设置如下:
红色标记部分为必选,尤其是Presentation
必须是Over Current Context
Notification
在App需要跳转到另外一个App处理一些事物再跳转回来,系统会调用AppDelegate一系列方法,此时如果需要当前屏幕上的ViewController来处理逻辑,可以在AppDelegate中选择分发Notification
NSNotificationCenter.defaultCenter().postNotificationName(消息名称, object: self, userInfo: 附加信息)
然后在ViewController添加消息监听器
NSNotificationCenter.defaultCenter().addObserver(self, selector: 处理消息的方法, name: 监听消息的名称, object: nil)
注意:一定要在ViewController即将销毁时删除所有监听器,否则该ViewController会无法销毁
- UIScrollerView在UINavigationController不显示的问题
UIViewController.automaticallyAdjustsScrollViewInsets = false
iOS 7 — navigationController is setting the contentInset and ContentOffset of my UIScrollView