Strange behavior of Split View Controller in iOS5 and iOS6 - ipad

I have a strange behavior of Split View Controller in iOS 5.0 and iOS 6.0 iPad simulators. I created Master View Detail template in Xcode and set deployment targets everywhere to 5.0. I switched Autolayout off and set orientation to landscape only.
My app works as follows - Split View Controller is my root VC and because I need to display login first I use
- (void)viewWillAppear:(BOOL)animated {
[self presentModalViewController:[self.storyboard instantiateViewControllerWithIdentifier:#"loginVC"] animated:NO];
}
in the MasterViewController. Everything runs smoothly on iOS 6 simulator, but the 5.0 just won't display the login VC and shows the rest in portrait mode, but turned to landscape. Picture attached below.
Anbody knows what could be wrong?

Related

How to enable UISplitViewController's preferredDisplayMode = .primaryOverlay setting for iPhone size class

I am trying to use the UISplitViewController for iPhone portrait mode (since it will use navigation controller instead).
I tried to set the UISplitViewController's preferredDisplayMode = .primaryOverlay (which let user to swipe in/out master view from the left). However, this setting only works for iPad and Plus. iPhone still keep using navigation controller, ignoring my setting.
My question is - how to use UISplitViewController for iPhone? I see that Outlook iOS app can do this so it should be possible.
Thanks.
The UISplitViewController only works on iPads. On iPhone it acts like a master/detail view controller. If you want that UI style for iPhone you'll have to implement it yourself.

iOS broken auto layout on simulator 7.1 after segue (works on ios 8)

I have very strange problem on ios simulator 7.1 with auto layout but on ios 8 everything works fine.
On ios simulator 7.1 when new "View Controller" was presented through segue its content becomes layout incorrectly and sometimes even moves.
Demo code on github:
https://github.com/Misterio26/iOS-7-Simulator-Bug-demo
This demo uses only interface builder, there's no hand code at all, that is why I very surprised about this bug.
To reproduce:
use xCode 6
run with ios simulator (7.1)
press "Works", you will see a test screen that is aligned correctly (sometimes not), then press "Back"
press "Bug", after screen appearance you will notice some ui movement and incorrect alignment (sometimes it shows constraints error in console log)
I log window.hasAmbiguousLayout in viewDidAppear, and it print "false" for iOS 8 and "true" for iOS 7. Looks like iOS7 creates wrong constraints for presenting view controller. I used "po [[UIWindow keyWindow] _autolayoutTrace];" and it confirmed my suggestion.
I can't belive that only I have noticed this problem.
Can someone help me to know:
Is it simulator bug or it happens on real device too? (I don't have ios 7 device, just 8, and apple doesn't allow to downgrade ios)
Or maybe it can be fixed?
Or you can only try to reproduce that window.hasAmbiguousLayout becomes "true" after segue (I think that it's very dangerous bug):
create new iOS project in XCode6
in IB create new View Controller with one button
in IB create second View Controller with any content
in IB create "show" segue from button to second view controller (command + drag from button to second view controller)
in CODE create new class #interface CustomViewController : UIViewController
in CODE add to CustomViewController
- (void)viewDidAppear:(BOOL)animated {
UIWindow* window = [UIApplication sharedApplication].keyWindow;
NSLog(#"viewDidAppear hasAmbiguousLayout %#", ([window hasAmbiguousLayout] ? #"true" : #"false"));
}
in IB apply class CustomViewController to second view controller
run on ios 8 and you will see "viewDidAppear hasAmbiguousLayout false"
run on ios simulator 7.1 and you'll see "viewDidAppear hasAmbiguousLayout true"
I think it's very dangerous behavior.

dismissViewController doesn't dismiss presented view controller when using universal storyboard

I have discovered a situation that causes dismissViewController:animated:completion to not dismiss the view controller that has been presented. While it does dismiss on iPad running iOS 8, it doesn't dismiss on iPad running iOS 7.1. I've tried self, self.presentingViewController, and self.presentedViewController - all do nothing. I've tried it with Xcode 6.0 and 6.1 beta. While I do believe this is a bug, what can be done to work around it and force dismiss that view controller, ensuring it will work for iPad running iOS 7 and 8 (presented as a popover), and iPhone running iOS 7 and 8 (presented full screen)?
I have created a very simple project you may use to try this: Xcode project zip.
Project setup:
Universal storyboard targeted to iOS 7+
Implement Popover Presentation segue
Implement ability to dismiss popover inside that popover
To encounter the unexpected behavior:
Open the provided Xcode project
Run the app on iPad iOS 7 Simulator
Tap the top cell to present the popover
Tap the cell in the popover to dismiss it
The problem is in the way you try to handle the popover. To close the popover you should use the dismissPopoverAnimated method instead of dismissViewControllerAnimated.
I think you will have to make more work to complete your task for targeting both iOS versions. The root view controller should have some property to store the created popover with PoppedUpTVC as popover content and the PoppedUpTVC has to ask the root view controller to perform dismissPopoverAnimated method on the stored popover to close it.
To get a reference to the popover, try this in prepareForSegue:
if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]]) {
UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
yourDestViewController.propertyToStorePopover = popoverSegue.popoverController;
}

To show master view alone in portrait mode

I am using a UISplitViewcontroller in my iPad app. My requirement is to show just the master view in portrait mode and both master and detail in landscape mode. I tried using a SplitView controller, but it only shows the detail view in portrait mode.
The delegate function splitViewController:shouldHideViewController:inOrientation: will show both master and detail in portrait, but that is not my requirement.
Also it is only supported from iOS 5.0 and my app should support iOS 4.3.
put
self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.allVisible
in your MasterViewController

iPad App Portrait Only?

My app is entirely designed for IOS6. I use an xib for the iPhone and another one for the iPad. My AppDelegate sets up a TabBarController, though there is no class for the TabBarController itself. The TabBarController has two tab items, 1 a NavigationController, and 1 a View Controller, each of which has its own class. I would like the iPad to be able to run in just Portrait mode, upside down, and normal. On the summary tab of Target in Xcode, I have supported interface orientations set to Portrait and Portrait Upside Down.
My understanding with iOS 6 is that you only need to put
- (NSUInteger)supportedInterfaceOrientations
in the highest parent controller of a class, and set which Masks you would like it and all the child containers to work with. So, in the Root View Controller of the Navigation Controller I put:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown;
}
And in each of the child classes, I put:
- (BOOL)shouldAutorotate{
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
return YES;
}
else
{
return NO;
}
}
I then put the same two methods in the 2nd Tab which was just a View Controller Class.
I installed the app on my iPad, and it worked fine in portrait mode, but did not rotate when I turned it upside down. I exited the app and turned the iPad upside down, but when I started the app again, it still stayed in the same spot. So, I killed the app completely, and started it from the beginning upside down. The splash screen was upside down, but when the screen disappeared, the app was still only showing in portrait mode, making the display upside down.
What am I missing?
click on appName select Target and just select the orientations which you want to support. thanks
The code above is great for pre iOS 6. For iOS 6 you have to use the mask orientation. If you want all of the views in iPad to rotate or just some you have the choice of using the above answer. If you want to hard code it the check my answer in the following link for a detailed code for autorotation of all masks or just rotate one view and let the others don't rotate. Any how here is the link
iOS 6 supportedInterfaceOrientations issue
The above answer is providing you with the right solution as well but if you want to learn how to code it check my answer in the link above. Happy coding.
Is the Rotation Lock enabled or not ? (If you are new to iOS, double tap the home button, and slide to the right: it's the little metal-styled button in shape of an arrow).
If you want to run your application to run on portrait mode only than,
1. Select Your Target.
2. In General -> Development Info -> Device Orientation Uncheck all other orientation.Portrait mode only should be checked.Than run your project.

Resources