How to do a popover with SplitViewController?

General discussion about iOS development - a great place to ask questions about iOS or help out others. For discussion of the official tutorials, see the Official Tutorials forum.

How to do a popover with SplitViewController?

Postby davidm71 » Thu Jul 26, 2012 4:51 pm

Hi,

Been trying to figure out how to suggest IOS to display its RootviewController tableview in the MasterViewController of a SplitView to display as a popup as opposed to a long tableview that slides in from the left? Been following the IOS Tutorials book and can't get the Popover behavior to appear unless you make a custom Segue in StoryBoard, but the default template is suppose to display as a Popover when in portrait mode??

Thanks!
davidm71
Hacker
 
Posts: 34
Joined: Tue Jul 24, 2012 12:15 am
Has thanked: 3 times
Been thanked: 1 time

Re: How to do a popover with SplitViewController?

Postby marciokoko » Thu Jul 26, 2012 5:23 pm

I can't look at my code at the moment because I made the mistake of upgrading to Xcode 4.4 and its taking forever to download.

But you can have a popover be called from the detailVC and have it present your tableVC. Did you try this:

Code: Select all
- (void)viewDidAppear:(BOOL)animated
{
    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) {
        if (self.view.window != nil) {
            [_masterPopoverController presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
        }
    }
    [super viewDidAppear:animated];
}
--------------
"Stay Hungry, Stay Foolish!"
Mars
santiapps.com
@santiapps
MBA-2011-iPhone5s-iPad3
User avatar
marciokoko
Team Member
Forum Subject Matter Expert
 
Posts: 2328
Joined: Wed Jun 08, 2011 9:37 pm
Has thanked: 4 times
Been thanked: 328 times

Re: How to do a popover with SplitViewController?

Postby bgulanowski » Thu Jul 26, 2012 5:28 pm

You might want to try sketching out your view hierarchy to make sure you have all the views and view controllers clear in your mind. I don't think that you want you rootViewController to be a subview of your split view. usually the split view is the root view controller, or it is contained in the root view controller. The root view controller is the root, so it shouldn't be contained in anything else.

I don't know the iOS Tutorial book, so I can't use that as a reference point to provide guidance. But your split view should have two subviews: a master and a detail. The master is usually a list of some kind. The detail shows contents of item selected in the list. So perhaps you are thinking of the "root view controller" as the root of your model hierarchy. Those are similar, but not the same. You should make a separate table view to hold your root object or class list (depends on your design). Then you want to update the contents (or the view, again, depends on the design) of the split view's detail view (the second subview) when the user changes their selection in the list view.
bgulanowski
Hacker
 
Posts: 26
Joined: Thu Jul 26, 2012 5:18 pm
Has thanked: 0 time
Been thanked: 2 times

Re: How to do a popover with SplitViewController?

Postby davidm71 » Thu Jul 26, 2012 6:19 pm

I'm sorry I was referring to the Navigation Controller that is the 'root view controller' of the Split View Controller. So yes the RootView Cntrler is the Splitview Controller that has two objects being MasterView Controller (housing the nav controller which encapsulates the table view controller inside the popover controller) and the DetailView Controller. Though that is not the issue which view controller goes where. The issue is even with the MasterDetail Template from the File menu or if I followed the tutorial to the letter I get the MasterView Controller sliding in from the left when I hit the TabBarItem in portrait mode on the Ipad Simulator instead of Popping or hovering in its own window. I've tried setting its pixel length in the storyboard controls or hard coding a cgrect in the delegate methods without success. I read a few accounts doing google searches on this that there may be an Ios5.1 bug thats causing this behavior change. Unfortunately I'm not advanced enough yet to figure out how to set it so it Popsup as opposed to sliding in place. Anyone shed some light please?

Thanks.
davidm71
Hacker
 
Posts: 34
Joined: Tue Jul 24, 2012 12:15 am
Has thanked: 3 times
Been thanked: 1 time

Re: How to do a popover with SplitViewController?

Postby bgulanowski » Thu Jul 26, 2012 7:04 pm

davidm71 wrote:The issue is even with the MasterDetail Template from the File menu or if I followed the tutorial to the letter I get the MasterView Controller sliding in from the left when I hit the TabBarItem in portrait mode on the Ipad Simulator instead of Popping or hovering in its own window.


OK, that's a little more clear. Unfortunately, you're assuming that we know which tutorial you're talking about. Do you have a link to the contents or source code for this tutorial? Did you compare your code to the finished code from the tutorial (if it has one)?
bgulanowski
Hacker
 
Posts: 26
Joined: Thu Jul 26, 2012 5:18 pm
Has thanked: 0 time
Been thanked: 2 times

Re: How to do a popover with SplitViewController?

Postby davidm71 » Thu Jul 26, 2012 9:32 pm

bgulanowski wrote:
davidm71 wrote:The issue is even with the MasterDetail Template from the File menu or if I followed the tutorial to the letter I get the MasterView Controller sliding in from the left when I hit the TabBarItem in portrait mode on the Ipad Simulator instead of Popping or hovering in its own window.


OK, that's a little more clear. Unfortunately, you're assuming that we know which tutorial you're talking about. Do you have a link to the contents or source code for this tutorial? Did you compare your code to the finished code from the tutorial (if it has one)?


I was doing the IOS 5 Tutorial from that this forum supports by Ray in the middle of Chapter 5 at the Start of IPad SplitviewController section. Though even without the tutorial in mind if you just make a MasterDetail Template in Xcode and compile it, should the side menu corresponding to the MasterController list while in Portrait ipad mode hover in its own window or slide in from the left? I was under the impression it should be hovering in a popover window?

Thanks.
davidm71
Hacker
 
Posts: 34
Joined: Tue Jul 24, 2012 12:15 am
Has thanked: 3 times
Been thanked: 1 time

Re: How to do a popover with SplitViewController?

Postby marciokoko » Thu Jul 26, 2012 10:00 pm

Do you mean you are following this tutorial:

http://www.raywenderlich.com/1040/ipad- ... w-tutorial
--------------
"Stay Hungry, Stay Foolish!"
Mars
santiapps.com
@santiapps
MBA-2011-iPhone5s-iPad3
User avatar
marciokoko
Team Member
Forum Subject Matter Expert
 
Posts: 2328
Joined: Wed Jun 08, 2011 9:37 pm
Has thanked: 4 times
Been thanked: 328 times

Re: How to do a popover with SplitViewController?

Postby bgulanowski » Thu Jul 26, 2012 10:57 pm

I've gone in and tried out some of my own code, and yes, I'm seeing the same thing. The table view slides in and out from the left instead of using a popover style bordered floating window. I think maybe Apple has just decided to change it up. Even though the behaviour is unexpected, it doesn't seem to be broken; it just looks different. Whether different means "wrong" I guess is an open question. I actually thought popovers for table views looked pretty ridiculous. This slide in/out behaviour is running amok, but I think it might work better in this case. I haven't checked the docs, but I would expect some kind of update about it pretty soon.
bgulanowski
Hacker
 
Posts: 26
Joined: Thu Jul 26, 2012 5:18 pm
Has thanked: 0 time
Been thanked: 2 times

Re: How to do a popover with SplitViewController?

Postby davidm71 » Fri Jul 27, 2012 12:03 pm

marciokoko wrote:Do you mean you are following this tutorial:

http://www.raywenderlich.com/1040/ipad- ... w-tutorial



No not that one. Its in the 'ios5 by tutorials' book under the intermediate Storyboard chapter. Thanks for finding a new one though. Will try it out!
davidm71
Hacker
 
Posts: 34
Joined: Tue Jul 24, 2012 12:15 am
Has thanked: 3 times
Been thanked: 1 time

Re: How to do a popover with SplitViewController?

Postby davidm71 » Fri Jul 27, 2012 12:11 pm

bgulanowski wrote:I've gone in and tried out some of my own code, and yes, I'm seeing the same thing. The table view slides in and out from the left instead of using a popover style bordered floating window. I think maybe Apple has just decided to change it up. Even though the behaviour is unexpected, it doesn't seem to be broken; it just looks different. Whether different means "wrong" I guess is an open question. I actually thought popovers for table views looked pretty ridiculous. This slide in/out behaviour is running amok, but I think it might work better in this case. I haven't checked the docs, but I would expect some kind of update about it pretty soon.


I like the standard non popup view better aswell but would like to know how to display the table in either format. There must be a way to present the view like that? In the tutorial they describe how to make your own tabBarItem which triggers a popover view segue that does just that by setting the particulars of the segue on the ui controls of the inspector panel, but the changing the default behavior is the question and if your interested in making a popover style app guess you wont need to use a splitview controller anymore?!
davidm71
Hacker
 
Posts: 34
Joined: Tue Jul 24, 2012 12:15 am
Has thanked: 3 times
Been thanked: 1 time

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 7 guests