Adding views to a rootController in a splitView - objective-c

I am playing a little with the split view of iPad and I want to add different views to the rootView of the split. I can add one image, one view of one of my view controllers but, instead of that, I have problems with de rotations.
For example, sometimes appear a white bar on the top and I can't do anything to move it. Does someones know how to add views to the rootView perfectly? Is this correct or I have to make other things.
Thanks
David

Finally I resolve the problem: When I dismiss the popover I have to get out the animation. If I do this, all works fine.
But if someone can tell me the best practices to how to put views in root controller please :)

Related

UISplitviewController and UINavigationController

I have a splitviewController for my iPad app that uses a uinavigationcontroller in its detail view (right view controller). Everything is hooked up in interface builder and after calling:
[self.window addSubview: splitViewCpntroller.view]
I get the left and right views to display.
The problem is, the navigation bar's y position in my right view is wrong and offset a bit (I think 20px) downwards so that there is a gap between the status bar and the right view's navigation bar.
I've spent the whole afternoon trying to figure out what's wrong but I didn't find anything. Since its all hooked up in IB I can't show you much code.
I'm sure it's a simple thing I'm missing and since it's IB it's probably hard for you to follow what exactly I was doing - but maybe one of you encountered this before?
This is one of those questions that comes up pretty often, but for some reason it's hard to remember the answer. However, I think the root of your problem is that your view controller's view has a height that's too small -- try adding 20 pixels to the height, and also check its position.

Flipping between views has UITableView position issue

I have a UINavigationController within a UITabBarController. Within the navigation controller I have a ViewController that looks after flipping between two views using transitionWithView:duration:options:animations:completion one of the views i am trying to show is a TableView.
The problem is when showing the TableView it is off position.
and the flip view
I have tested flipping between two standard views without issue, it is only the TableView that shows off position. Also when the Tableview has more data then can be shown on screen the bottom rows are hidden by the Tabbar. It looks like the frame size is wrong but I am not sure how to proceed to fix the problem.
Full test project and code can be found on GitHub
Any suggestions or help is greatly appreciated.
The root of the problem is that you are using UIViewControllers (FlipSide and FlipMain) as subviews for FlipController which is itself a UIViewController. Prior to iOS 5 this was not supported and inevitably led to problems. iOS 5 adds support for a view controller hierarchy but requires that you use the appropriate new methods.
You have a couple of choices: restructure the view controllers so they are not nested, rewrite the sub-controllers as UIViews, or use addChildViewController to add the subcontrollers.
I've forked and modified your original code here to illustrate that changing to UIViews resolves the problem with layout.
It's a bit hard to answer without the full code, but I would try playing with the "wantsFullScreenLayout" property of your view controllers. I say that because the offset seems to be 20px high, which corresponds to the status bar's height...
Let me know if this helped ;-)

Can a splitview be loaded inside the detail view of another splitview?

I am trying to develop an application that has screen flow similar to oracle app. I have attached the images here. Can anyone please tell how this can be achieved ?
Thanks in advance.
What you are looking for is a custom Split View Controller. The screenshots you provided are of custom split view controllers. The UIKit has UISplitViewController but this must be a fullscreen view controller.
To make a custom split view controller there's the old way, by having a main view controller and making your two master and detail controllers, adding their view to the main view controllers view.
You need to forward on calls from viewWillAppear:, viewWillDisappear: etc from the main view controller to the two controllers that you manage.
As of iOS 5, you can do something similar with view controller containment, this has a few more bells and whistles, more interesting it handles rotation animations better and all the call forwarding to the children controllers that you had to do manually in the first solution.
Check out this link for more details on custom split view controllers:
http://www.mindtreatstudios.com/how-its-made/custom-uisplitviewcontroller-ios/
To answer your question directly: if you make a custom split view controller - yes you can add this as a detail view controller. But watch out, this isn't a UISplitViewController, so just be careful not to use that term so much.
Haven't really tested this, but doesn't this solve your problem?
Create a storyboard file
Drop in a SplitViewController
Delete the DetailViewController
Drop in another SplitViewController
Link the two together using CTRL-drag and select Detail
Set the size of the detail-splitviewcontroller to Detail
????
Profit!
Anyways, not sure if it really works, but give it a try. This is IOS5 though (I think, might try it out with IB).
It'll look something like this:
If you're going to have to write your own class, you might want to first look at https://github.com/mattgemmell/MGSplitViewController for inspiration.

May I add a second subview to window if rootViewController is a UISplitViewController to simulate a modal effect?

I'm currently using UISplitViewController as my app's rootViewController. To present progress dialogs I use presentModalViewController, but for the one and other reason I'm not entirely happy with it and want to do my own modal thing.
If one of my modal views is supposed to be shown, I want to add another subview to my app's main window. This subview is going to be managed by its own UIViewController subclass to make it rotate properly and do all the stuff I need.
Is this design aproach okay or will I run into issues with UISplitViewController (it is very special in so many ways and seems to be offended easily if not treaten right! :-))?
Is it a problem to have two UIViewControllers next to each other?
Please don't discuss "why don't you use presentModalViewController then?".
You may be ok with UISplitViewController if you do it properly, as presentModalViewController does something similar.
One alternative you should look into is UIPopoverController and the UIViewController's modalIfPopover property.
Also, you say you aren't happy with presentModalViewController and perhaps if you say what was wrong with it we can help you work around whatever issues you have with it. This is the exact case that it seems to be meant for.

Why does the iPad stop auto-rotating when I start overlaying View Controllers?

I have a fairly hefty project, where I am loading a few view controllers, one after the other. First, a splash screen, followed by a menu system, and when the user clicks on the menu it goes through to an article view controller.
Putting all these in with shouldAutorotate... set to YES for all rotations, this works fine. However, I have a menu bar I need to slide down over the top when a tap gesture has been recognised. I have one for the main menu, and one for the article view.
If I put one of these in, it still auto-rotates fine. However, as soon as I put the next one in, the auto-rotate stops working. I've tried putting the menu bars in the app delegate, as well as nesting them inside the menu/article view controllers. The Menu Bar view controller also has shouldAutorotate... set to YES. In fact, every single view controller in the project (all 7 of them) have it set to YES. And yet, when I add my second Menu bar controller, it stops auto-rotating. It doesn't even trigger the "shouldAutorotate" method to ask it.
The code is way too large to post here, but if you'd like to see anything in particular then just ask. I'm totally stumped! I'm about to pull the menu bars out of their view controller and code them up in each of the view controllers individually. This will be a hideous amount of code duplication, but I can't think of any other way round it!
Any ideas? Thanks!
The answer appears to be... Don't put view controllers within other view controllers! One view controller = one screen, seems to be the rule. I have a lot to learn!