I have a navigation based app that has a detail view (UIWebView) with action buttons across the bottom in a UIToolbar. I want to add \'notes\' when the \'notes\' button is
Wow, I lost days over that issue ... but I found a solution!
I had the same problem you had: the method "presentModalViewController:animated:" only worked in portrait mode.
After a lot of trial and error, I found out that the reason was that I had several view controllers active at the same time. I implemented a navigation system which switched between different view controllers, with one parent handling the children. (I could not use UINavigationController, because I needed a different look.)
So, my root view controller had a root view object, and several child view controllers. When a child view controller was activated, its view object was added as subview to the view of the root view controller.
The "presentModalViewController" method didn't like that. However, as soon as I set the "parentViewController" property of the child view controllers, it worked!
The problem is only that "parentViewController" is a read-only property. You have to extend the UIViewController class so you can access it.
@interface UIViewController (HelperExtension)
@property (nonatomic, assign) UIViewController *parent;
@end
@implementation UIViewController (HelperExtension)
- (UIViewController *)parent
{
return self.parentViewController;
}
- (void)setParent:(UIViewController *)parent
{
[self setValue:parent forKey:@"_parentViewController"];
}
@end
So, whenever you add the view of a child view controller to your parent view controller, call the "setParent:" method after doing it. Then it will work!