I have a View controller with an embedded Container View plus a controller
The Container View hosts a UIPageViewController The View controller has a button, if its clicked I want to update a label in the current displayed page managed by the UIPageView Controller
I am getting the ContainerView Controller with this approach
@IBAction func sendButtonTouched(sender: AnyObject) {
if let vc = self.childViewControllers.last as? ContainerViewController{
vc.pageViewController.view.backgroundColor = UIColor.blueColor()
I get the UIPageViewController and set the color but it does not update
also if go deeper into the rabbit hole to get my currently viewed page I am able to get and set all values but my view never updates
what I really want to do is something like this
@IBAction func sendButtonTouched(sender: AnyObject) {
if let vc = self.childViewControllers.last as? ContainerViewController{
vc.pageViewController.view.backgroundColor = UIColor.blueColor()
print("make it blue baby")
if let pageItemController = vc.getCurrentViewController(){
print(pageItemController.indexLabel.text)
pageItemController.message = self.messageTextView.text
pageItemController.messageImage.image = UIImage()
pageItemController.reloadInputViews()
}
}
}
and in ContainerViewController
func getCurrentViewController()-> MIPViewController?
{
print("\(self.pageViewController.viewControllers!.count) view controllers")
if let vc = self.pageViewController.viewControllers!.first as? PageItemViewController
{
if vc.index < mipCount
// must be a MIPViewController
{
return vc as? MIPViewController
}
}
return nil
}
in my console output i see
make it blue baby
1 view controllers
Optional("This is a message of the number 0")
Optional("")
so everything is called but as stated no view ever updates
I am probably missing something really basic here, so thank you for your help I also checked other questions e.g. Access Container View Controller from Parent iOS but afaik using the childViewControllers is also valid