I have a SplitViewController. In the master view I have a toolbar that is attached to the status bar.
When I launch the app in landscape mode (master view is visible), it looks great:
I launch in portrait:
After launching in portrait I rotate the screen to landscape. The master view appears as it should, but the toolbar is no longer attached to the status bar.
As you can see the toolbar is too small now and runs into the status bar. I have the delegate setup correctly to tell the toolbar to attach to the status bar. This problem only seems to happen when I start the device in portrait and rotate it.
I have tried to force the master view to re-layout by calling setNeedsLayout in viewWillAppear but that makes no difference.
Please help!
Just a guess, but make sure that in your view controllers that this is set appropriately:
- (BOOL)prefersStatusBarHidden
{
return NO
}
Related
Recently I ran into an issue with my app when changing the device's orientation.
This is my main ViewController (let's call it VC1) in portrait mode:
Now if you push / present any viewcontroller (let's call that VC2), rotate the screen while in VC2, and return back to the previous view (VC1), this is what I get:
Why doesn't VC1 rotate correctly like it should? This issue happens throughout the whole app and with any two views. I honestly have no idea what might be causing this or where to look, so any help would be appreciated.
Do you use constraints and autolayout? Can you post a screeen where constraints of the view are visible? I think there are some missing constraints
your navigation bar is properly resize in portrait and landscape mode So The main problem is you didn't add trailing Constraints to your view.
Just Add you trailing constraints on your view in Storyboard.
I have 2 views. A portrait detail view that when rotated to landscape, does a manual segue to a full screen photo viewer. The portrait detail view returns NO for shouldAutorotate and prefersStatusBarHidden.
When I rotate from portrait to landscape, just before the landscape view fades in, I can see the portrait view resize slightly as the status bar gets hidden and then the status bar moves from the top to the side.
The transition looks a bit ugly. I'd rather the status bar remains visible as the device is rotated to portrait, since it will get covered over by the landscape view anyway. Is it possible to do this?
I don't think this is possible.
The only way I see it working is if you do the rotation yourself and not with the device ability
I have a tabbarcontroller with 3 tabs that are splitviewcontrollers.
It works fine except when:
in portrait view tap the rootview button to show the master
popover.
switch to any other tab
rotate to landscape (the masterview controller of that tab appears)
switch back to first tab and the detail view controller is in the
right position (320 px from left border) but instead the master view
I have a black screen
I enumerated the splitviewcontroller subviews but the masterview is not there.
If I rotate the device in portrait and back in landscape, the master view appears.
I try to better explain with this picture:
It seems to me that the problem might be caused by all of your UISplitViewControllers using the same delegate, probably your AppDelegate. That might cause the behavior you're seeing, since when one UISplitViewController returns false from collapseSecondaryViewController:ontoPrimaryController, they all will return false, giving you the padding on the left to make space for the masterViewController. But your UISplitViewControllers which are not active aren't showing the masterViewController, so you get a blank space, instead of what you expect.
At the start, my application shows full screen view (320x480) without status bar. After a user do some selection, the app uses +[UIView transitionFromView:toView:duration:options:completion:] to switch to normal view with status bar. Unfortunately, during transition it seems that toView has size 320x480, so part of the view is below status bar. Just after transition completes, view is resized to 320x460 (as it should be initially).
My question is how can I force the view to be resized correctly before transition.
I had a similar but not identical problem. Try the solution given here, which worked for me (basically, using setAnimationsEnabled: to disable part of the animation):
RootViewController animation transition, initial orientation is wrong
I got a UINavigationBar with an .rightBarButtonItem. If I tap on it, it pushes the new viewController and a .leftBarButtonItem is brought up automatically which takes me to the viewController I was before.
The problem is (when I tap on the .leftBarButtonItem) that the orientation is changed from landscape to portrait mode, though I want the app to stay in landscape mode. How can I fix that?
Thanks a lot!
It's not clear if you were in portrait mode before you pressed the right button bar item.
It sounds like the first view controller's shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation isn't returning YES for portrait orientations.