presentModalViewController not taking full screen
Landscape only app. On my main window xib, I've got a UIView. I'm loading a UIScrollview programatically into that UIView which works just fine. On that scrollview, I've got a button that brings up a "detail" screen (a separate view controller), via a presentModalViewController call:
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self presentModalViewController:learnit animated:YES];
[learnit release];
The action's being called but the modal view doesn't take up the whole screen when the scrollview is a subview. Instead, it's popping into the parent scrollview and flipping the orientation, etc. Not the desired behavior.
Any guidance on how to make the modal view full screen when the call is 开发者_StackOverflow社区from scrollview which is a subview of a container UIView on the main xib?
Thanks for all the comments. Found a tip somewhere on overriding presentModalViewController and bubbling up in a loop until the main controller's reached (in my case, HomeViewController). Worked like a champ.
- (void) presentModalViewController:(UIViewController *)screen animated:(BOOL)animated {
UIResponder *responder = self;
while (responder && ![responder isKindOfClass:[HomeViewController class]]) {
responder = [responder nextResponder];
}
[(UIViewController *)responder presentModalViewController:screen animated:YES];
}
I'm overriding in the .m file of the UIScrollview that contains the button that makes the call.
Try adding subview
, rather than presentModelViewController
as:
LearnITViewController *tempView = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:[NSBundle mainBundle]];
self.learnITViewController = tempView;
[tempView release];
[self.view addSubview:mainMenuView.view];
And add This too
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);//or left
}
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.learnitView setsetWantsFullScreenLayout:YES];
or
self.learnitView.wantsFullScreenLayout = YES;
[self presentModalViewController:learnit animated:YES];
[learnit release];
Instead of self
add UIViewController
in superview
.
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.view.superview presentModalViewController:learnit animated:YES];
[learnit release];
精彩评论