以编程方式完全终止ViewController在Swift中
当我使用NotificationCenter发送通知时,以前打开的ViewController(使用不同的数据)响应我的通知。例如以编程方式完全终止ViewController在Swift中
A至具有x数据 A B与Y数据 A到B地z数据
这种情况下后(B中的ViewController),至B当我推通知,通知观察者主叫3次。
我使用Storyboard和编程导航控制器。
在ViewWillDisapper中:(A类)removeObserver进行通知。并在ViewWillAppear(A类)addObserver for通知。 也遵循相同的B类。
我试过了,但不起作用。 B viewcontroller有一个ContainerView。这是一个pageviewcontroller。那是问题吗? – tersintersi
不,我想我不会是一个问题。我可以知道你在哪里添加和删除通知观察员? –
您需要删除通知观察者在Bviewcontroller
添加波纹管法Bviewcontroller
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
还是你面对这个问题? –