I have two view controllers, one is presenting the other modally with -presentModalViewController:animated:, and the second controller has a view with a button that should close it by calling parents -dismissModalController which just cals -dismissModalViewControllerAnimated:.
The problem is that I can't use parentViewController property of second controller to set a target for the dismissing action:
This ends with unhandled exception when I press the button.
Then I added realParentController property and -initWithRealParent: method to the second controller and when I changed the code above to use that new property, the modal view closed ok without any unhandled exceptions.
I can see in debugger while I'm in -loadView that the parentViewController property of the second controller is not nil, but why it isn't the right pointer to the parent controller?
The problem is that I can't use parentViewController property of second controller to set a target for the dismissing action:
Code:
[theButton addTarget:self.parentViewController
action:@selector(dismissModalController)
forControlEvents:UIControlEventTouchUpInside];
Then I added realParentController property and -initWithRealParent: method to the second controller and when I changed the code above to use that new property, the modal view closed ok without any unhandled exceptions.
Code:
[theButton addTarget:self.realParentController
action:@selector(dismissModalController)
forControlEvents:UIControlEventTouchUpInside];