Presented View Controller Has Wrong Frame When Orientation Changes - objective-c

I have a custom UINavigationController (only customized to standardize colors and a few other things) that I use throughout my iPhone app. When I rotate my phone, everything works fine. Unfortunately, when I use said controller with presentViewController, things get weird after rotating.
Do I have to do anything special with a view controller that is presented to make it play well with orientation changes?

Something similar happened with my app.
I was presenting the view controller from a ChildViewController. I changed the presenting view controller to the parentViewController instead of the childViewController, and it worked properly.
I hope this help you!
Regards,
Martin.

Related

Disabling buttons before view rotates

So been working on another app recently for iOS which incorporates a UIImagePickerViewController. App is ready to go and all works fine under normal circumstances, but if the user is being eratic and pushing buttons whilst rotating the iPad, then things go slightly awry and views load in the wrong place.
So basically, I want to disable all my buttons before the iPad is rotated and enable them again after the view is done rotating.
I thought this would be easy using the
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
and
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
methods.
But because the UIImagePickerController is being displayed, this for some reason stops these methods from being called. So I can't use these methods.
So basically, what I'm asking is if anybody can think of any other ways that I could achieve this??
Thanks,
Matt
You could subclass UIImagePickerController and then implement those methods on your UIImagePickerController subclass.

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.

Adding views to a rootController in a splitView

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 :)

How to get UINavigationController to rotate, but not the subview?

I downloaded the free iPad application "SketchBook Express" by "Autodesk".
In it, they have a drawing surface, and (what I believe is) a UINavigationController. What interests me is that the navigation controller bar rotates with the iPad, but the content of the drawing does not. So if I put the iPad from portrait to landscape, the nav bar moves to the new top, but the sketch I've drawn is now on its side. I would like to implement something similar for my program, but I have been unable to.
I've played with shouldAutorotateToInterfaceOrientation: but so far I've just figured out it is only called once. I made a subclass of UINavigationController and had that return YES, and had my subview controller return NO. That did not do the trick.
Is there a simple way to do this?
What rotates is probably contained by a UIViewController (or UINavigationController)'s view.
Other things (that don't rotate) are probably contained by a view that is not contained by any UIViewController (or a controller that returns NO in shouldAutorotateToInterfaceOrientation method).
This means that you could try setting your drawing view as a subview of the keyWindow.
Other things could be in the view controller as usual.
Is not I have tried, this is just an idea. And I would be interested in knowing if this worked. :)

Couple of questions about iPad dev (from iPhone)

I am starting to develop an iPad app I have a couple of questions:
For UISplitViewController, how do I change the detail view controller (the one on the right with the controller on the left hand side)? Or do I need to have a Navigation Controller and continuously push view controllers?.
I have a UITableViewCell that's designed for landscape mode. Do I have to setup a separate one for portrait mode?
Is there a way I can zoom out in Interface builder so I can see the entire iPad layout (I am using XCode 4.0.2)
Thanks!
 1. You can change the two controllers by changing the viewControllers property of your UISplitViewController. If you want to keep the one on the left, you could do
[splitVC setViewControllers:[NSArray arrayWithObjects:[splitVC.viewControllers objectAtIndex:0], myNewViewController, nil]];
Though I believe that won't animate the transition. For this, you could use a classical view controller as your right-hand view, and do the transitions inside of it.
 2. No need to do a separate design if you've set your subviews’ AutoresizingMasks appropriately. See the documentations on this, it's quite handy for this kind of situation.
 3. Dunno, I have a huge monitor, I'll leave this one to others :p