Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 7, 2010, 11:08 AM   #1
seepel
macrumors 6502
 
Join Date: Dec 2009
Modal View Controller from Root View Controller in UISplitViewController

I am trying to present a modal view over my root view controller in a UISplitViewController app. Here is the relevant code.

Code:
modalViewController.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentModalViewController:modalViewController.navigationController animated:YES];
This works fine when the app is in portrait orientation and the rootViewController is in a popover. And in landscape orientation it will work if the modalViewController has already been presented in portrait orientation. However, if I try to present the modal view controller for the first time in landscape orientation it will not display, and it seems as though the modal view picks up the wrong frame.

Anyone have any ideas?
__________________
Free iOS App that turns your music library into an info graphic.
Phonographic
seepel is offline   0 Reply With Quote
Old Aug 7, 2010, 11:51 AM   #2
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
Apparently presenting modals from a popover isn't supported.

Hmmm. Maybe that's not relevant. Dunno.
PhoneyDeveloper is offline   0 Reply With Quote
Old Aug 7, 2010, 07:12 PM   #3
seepel
Thread Starter
macrumors 6502
 
Join Date: Dec 2009
Quote:
Originally Posted by PhoneyDeveloper View Post
Apparently presenting modals from a popover isn't supported.

Hmmm. Maybe that's not relevant. Dunno.
According to the documentation modal view controllers are supported for popovers with UIModalTransitionStyleCoverVertical which is what I'm using. It also works fine in the popover. In fact it only works reliably in the popover. If I present the controller in the popover, then present it again after rotating to landscape, it works fine. If I try to present it in landscape for the first time it won't show up. It seems like something gets set when I present it in portrait/in the popover, but for the life of me I can't figure out what it could be. Also, looking at the fram of the modal view it seems like it is picking up the frame that it would have in portrait, even though the device is in landscape.
__________________
Free iOS App that turns your music library into an info graphic.
Phonographic
seepel is offline   0 Reply With Quote
Old Aug 11, 2010, 02:58 PM   #4
seepel
Thread Starter
macrumors 6502
 
Join Date: Dec 2009
Well, it probably isn't the most elegant or robust, and I'll probably have to clean it up later, but I have temporarily rolled my own modal view presentation with the following code. I'd still be very interested in getting this working the correct way, but for now I guess this will suffice.

Code:
- (void)presentManageViewController {
	self.manageViewController.navigationController.view.frame = CGRectMake(self.navigationController.view.frame.origin.x, 
																		   self.navigationController.view.frame.origin.y+self.navigationController.view.frame.size.height, 
																		   self.navigationController.view.frame.size.width, 
																		   self.navigationController.view.frame.size.height);
	[UIView beginAnimations:@"presentManageViewController" context:nil];
	[UIView setAnimationDuration:0.3];
	self.manageViewController.navigationController.view.frame = self.navigationController.view.frame;
	[self.navigationController.view addSubview:self.manageViewController.navigationController.view];
	[UIView commitAnimations];
}

- (void)dismissManageViewController {
	[UIView beginAnimations:@"dismissManageViewController" context:nil];
	[UIView setAnimationDuration:0.3];
	self.manageViewController.navigationController.view.frame = CGRectMake(self.navigationController.view.frame.origin.x, 
																			self.navigationController.view.frame.origin.y+self.navigationController.view.frame.size.height, 
																			self.navigationController.view.frame.size.width, 
																			self.navigationController.view.frame.size.height);	 
	[UIView commitAnimations];
	[self.manageViewController.navigationController.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.3];
}
__________________
Free iOS App that turns your music library into an info graphic.
Phonographic
seepel is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Modal view controller presenter problem moonman239 iPhone/iPad Programming 4 Mar 6, 2014 04:47 PM
Resolved: How do I make a modal view controller's presenter do something when the MVC is done? moonman239 iPhone/iPad Programming 5 Mar 4, 2014 02:07 PM
About push view controller into a navigation controller stack. cthesky iPhone/iPad Programming 5 Nov 9, 2012 08:36 AM
Segue from Normal View controller to navigation controller daproject85 iPhone/iPad Programming 0 Sep 29, 2012 03:26 PM
push to a specific view controller regardless of which controller is active johnmerlino iPhone/iPad Programming 2 Jun 19, 2012 02:24 PM

Forum Jump

All times are GMT -5. The time now is 06:42 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC