Disabling buttons before view rotates - objective-c

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.

Related

Presented View Controller Has Wrong Frame When Orientation Changes

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.

iOS6 rotate methods not called when launching in landscape

Let me start off by saying I'm not having a problem when rotating views in iOS6 after the app is open. This issue is only happening for me when the app is launched for the first time while in landscape. The new shouldAutorotate and supportedInterfaceOrientations methods are both called when launched, however none of the rotation methods are called, like willRotateToInterfaceOrientation:duration:. (shouldAutorotate is always returning YES, and supportedInterfaceOrientations is always returning UIInterfaceOrientationMaskAll)
In iOS5, the 'first' orientation to landscape on launch was taken care of automatically. Is there an explanation for why the device wouldn't call this first landscape rotation in iOS6? (The view controller I'm checking is the root controller of the window/app delegate).
Thanks in advance for any help with and insight into this.
I suppose that since the interface is not actually rotating, that the method isn't being called.
If you want to do some setup based on the orientation, have you thought of using the view controller's intefaceOrientation property?
You should now use the viewWillLayoutSubviews method and not willRotateToInterfaceOrientation:duration:. The reason is because willRotateToInterfaceOrientation:duration: is not guaranteed to be called in a number of situations.
This is stated in the iOS6 release notes among other places.

How can I do an animated switch to UISplitView?

I have looked at the sample generated by xcode when creating a new UISplitView app on the iPad along with countless other tutorials and the documentation from the apple developer site. I have not seen an example where the UISplitView used was not the root of the application. Is this even possible?
What I am trying to accomplish: I have a UITableView to start out and once an item in the list is selected I would like to display a splitview with two different sets of information that is based on the item that was selected.
I curious if this type of implementation is even possible, or just frowned upon, and why. If it is possible, how would I go about implementing and hooking up a UISplitView to behave in this way?
Edit: I'm updating this with what I have. I can now switch to my UISplitView, though the transition is not animated. What is the way to correctly switch to a UISplitView so the transition is animated?
Code for switching right now:
[appDelegate.window addSubview:appDelegate.splitViewController.view];
appDelegate.window.rootViewController = appDelegate.splitViewController;
EDIT 2: In hopes of bumping this back up so more people see it, I have managed to switch from my navigationController to my splitViewController, but when I add the button to be able to navigate back, nothing I do makes a difference and I seem to be locked in. I tried reverse mirroring the code to switch to the splitViewController, but that had no affect, and I am completely out of ideas. Can anyone shed some light on this?
You should always use SplitViewController as a rootViewController: Split view controller must be root view controller
There may be some hacks around it, but when Apple have a strong recommendation and design guidance, I suggest to try to re-think your design before going against the platform -it should save you effort in the long term.
I recommend using the MGSplitViewController, it also works as a non-rootViewController, even nested into an another MGSplitViewController, and there's i.e. a one-liner for the animation to blend in the Master-View, if that is what you want.
In your UITableView didSelectRowAtIndexPath method you would have something like:
UISplitViewController *mySplitView = [[UISplitViewController alloc] init];
[self.navigationController pushViewController:mySplitView animated:YES];
[mySplitView release];
Probably you'll want to subclass UISplitViewController just like you would other view controllers and set in there the master and detail views and so on.

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

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.