Reputation: 7092
I have a container view controller with its own view controller class and some UI components. Some events of this container view controller needs to call the main view controller. I'm not able to find how to do it.
class mainViewController :UIViewController {
var containerView:UIView!
}
class MyContainerView:UIViewController {
@IBAction func buttonClick(sender:UIButton){
// change mainViewController background for example
}
}
Upvotes: 0
Views: 225
Reputation: 5248
You should register your main view controller to listen to local notifications broadcast from your container view controller to know when it needs to perform some update function or change the UI.
In your main it would be
NSNotificationCenter.defaultCenter().addObserver(self, selector: "performUpdates:", name: "ContainerViewChangedUpdate", object: nil)
Make sure to unregister in viewWillDisappear
.
In your container view controller you would send the notification.
Upvotes: 2
Reputation: 1508
So you are trying to get the parent controller right ?
self.parentViewController
Upvotes: 4