I am pretty new to iOS and Objective-C but I am trying to create an iPad app with a vertical tab bar down the left hand side and a split view controller taking up the rest of the screen. To achieve this I have put two container views on a page then embedded the splitview controller in the right container.
Here is my story board:
This works fine in landscape, however when I rotate to portrait the split view controller does not rotate as normal and this messes up the whole layout.
Here is what it looks like in landscape, as expected:
Here is what it looks like in portrait:
I've tried various things like manually forwarding willHideViewController and willShowViewController from the container to the splitview controller...
Is there something I'm missing? Or a better way to achieve the layout I'd like?
What happens is, in portrait mode the master view controller is transferred to a popover, which is normally placed off-screen to the left of the detail view controller. In your case, you can see it is also to the left, but this is the incorrect behavior for your case.
Implement the split view controller's delegate protocol, specifically splitViewController:shouldHideViewController:inOrientation: and return NO for any orientation.
Related
I'm currently working on a small iOS camera app and have a storyboard-related question.
(Sorry for my bad drawing) Here is what I got on my storyboard, I have two view controllers, mainVC and cameraVC, and I added table view cells to mainVC to add a segue to cameraVC. This app is a vertical orientation app, and I want to make this app horizontally only when the user gets to the cameraVC. I'm not planning to make this app rotatable, hence this app only supports the vertical orientation if the user is in MainVC and only supports the horizontal orientation if the user is in CameraVC.
I'd add several more vertical view controllers later on, so I make the app vertical on the storyboard. However, I was not sure how should I design the camera VC on my storyboard.
While the app is running and the user gets to the camera VC, I want the app orientation horizontal (and don't rotate to vertical) and display buttons on the right side, like the image below.
So my question is while all the view controllers set to vertical, should I place buttons on the cameraVC at the bottom like the first image, or is better to place buttons on the right side with assuming the VC rotates when the user gets the camera VC, like the image below?
Sorry for the confusing question.
When designing a view controller in storyboard there is no property for orientation. There are however simulated values that are applied to whole storyboard to be either landscape or portrait.
If you want to simulate these values differently I suggest that you move your camera view controller to another storyboard. I would actually do that regardless of the issue you are facing.
If this doesn't suit you for any reason then you can still simulate your view differently. You can simply select your camera view controller in storyboard and use a Freeform simulated size like on the screenshot below.
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 an iPad app which supports all orientations and has a UITabBarController managing a set of view controllers. Rotation works as expected everywhere. Keep in mind my UITabBarController is the .rootViewController of my app's UIWindow.
I now go to present a UIViewController modally from my UITabBarController. It presents well, and the status bar moves in accordance with the device's orientation. However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This isn't an issue on iOS 8, and I thought UITabBarController would handle a modal controller on its own. Is there something I'm missing?
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This is expected. In iOS 7, rotation was implemented by applying a transform to the top-level view controller's view. The application of this transform does not alter the frame, which remains in portrait dimensions. In iOS 8, rotation is implemented at the window level.
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
The UIModalPresentationStyleFullscreen presentation style removes the presenter's view from the window while it is covered by the presented view controller. If you modify the alpha of the presented view controller's view, you'll just see black underneath.
Since UIModalPresentationStyleOverFullscreen did not exist in iOS 7, you would need to use UIModalPresentationStyleCustom with your own transition animator. Unfortunately, custom transitions with view controllers that can rotate is extremely buggy in iOS 7.
The app I am building is having some issues when navigating in landscape mode.
This is how the table looks in portrait
but if I go to one of the child navigation items rotate and then navigate back in landscape it looks like this
I have tried everything I can think of and cannot fix it, I am using auto layout and storyboards
I'm guessing the table view isn't the main view of the view controller (i.e., self.view). Perhaps you dragged a table view from the object library onto the canvas for your view controller's storyboard scene. When you do that, the default implicit constraints created by Xcode will produce the situation you described upon rotation. You need to create your own explicit constraints in the storyboard that pin the four sides of the table view to its superview.
I am using master detail layout in my application. Every thing works fine, but when i clicked on the menu the popover comes and it is placed above the detail view. like this
actually in the detail view i have some videos displayed, like this..
when the popover come the videos are not visible, how to resize the detail view so that it moves right automatically when popover comes and the details are displayed like in case of landscape mode. Thank you..
This is how a UISplitViewController works when in portrait orientation. The detail view can't be resized.
However, just before the popover slides into view, the splitViewController:popoverController:willPresentViewController: delete method will be called. You could implement this and adjust the views in your detail controller to shift as needed. But this would not be standard behavior.