Parent UITableViewController not rendering when child rotates - ios

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.

Related

A vertical orientation app with one view controller horizontal orientation. How to design on the storyboard?

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.

Weird scrolling behaviour when using Tab Controller - iOS

I am building an iOS app using Swift. In my app, I am using a paging menu controller (called PageMenu) built from other view controllers placed inside a scroll view (you can view it on GitHub here). It is similar to how Instagram looks:
When I set up the PageMenu in my project, it looks and works great...
BUT, when I embed the view within a Tab Bar Controller to add in a normal iOS Tab Bar, the scrolling within the PageMenu view doesn't work...and I get weird diagonal scrolling, and I can't actually scroll down if there is more content.
Does anyone have any idea of why this might be happening and how to fix it?
Please ensure that you set up the frame size when you are initializing the page menu.
If your scroll view is bigger than the actual view, then you will only be able to scroll the view, and not scroll the content inside it properly.
Set up the frame size of view while embedding. Check the parent view frame size.

iOS7 SplitviewController embedded in ContainerView does not rotate

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.

Toolbar hiding on rotated UISplitView DetailView

I've based my app on Apple's SplitView project type. I have a TableView as the Master, and am using different types of views as the Detail view. To select types of detail view, I'm using the fancy concept of buttons on my DetailView toolbar. When the DetailView is derived from UIViewController, everything is good. When the DetailView derives from UIViewController, but contains a UITableView then I have problems. In portrait view the toolbar is visible. In landscape mode the toolbar is hidden, even though the Tableview is moved down to allow space for it. The UIToolbar and UITableView are both defined in my NIB file which is loaded to create the detail view. Why is my toolbar invisible in landscape?
BTW, is this the best way to choose Detail view types with UISplitView? Bonus question, what if selecting a row in my DetailView tableview should bring up another View, I can't push it like I would with a NaviagtionController, so how do I go back to the detail tableview?
Thanks, Gerry
HI Gerry,
I have faced the same toolbar problem, when trying to rotate the splitView, toolbar will disappear. If you are creating the toolbar in the interface builder, try to set the toolbar properties(size), by selecting the toolbar, then --> Tools -->Size inspector, in the autosizing section, mark the left, right and upper red lines and unmark the bottom red line, then everything will works fine.
-Maria
Bonus question, I would create a UINavigationController in code, set it's rootcontroller to the DetailView tableview (self) and then push the new view on top of it.
When you react to the rotation change are you using the same view or a different one for the detail view? Seems like the new view may not contain an instance of the toolbar? Or the Tableview is covering it up because the landscape view has less vertical room than the portrait view. Are you resetting the height of the tableview to allow space for the toolbar within the 768 height when rotating to landscape?
Just a tip but whenever I run into odd things like this I remove the elements from the NIB file and create them programmatically in code and it usually solves the problem. You get a lot more control over things when you do. Overall as I've gained more experience with programming for iPhone OS I've found that I rarely put much into a NIB file any longer and do almost everything in code now.

UISplitViewController Common View

is it possible to have a common view for both master and detail view controllers.
What if I need to add a header image(at top, the very first view) common for both the master and detail view controllers. When the device is in the portrait mode the width of the header image view has to shrink to fit to the detail view controller's view and when the orientation changes to landscape the width of the same header image view has to be expanded that is the width of it has to be 1024. Please tell me whether doing this is possible. or any workaround for this?
I'm not sure about this, but you may need to explicitly set the image using a UIImageView in your DetailViewController and your RootViewController NIB. Then, during an Orientation change (Portrait -> Landscape), the UIImageView in the DetailViewController should automatically flip with the rest of the ViewController, giving you what you are looking for.
A splitViewController must be root view controller in your application. If you add splitViewController's view as a subview of some other viewController's view, splitViewController will not get the rotation events.
For your problem, change the design of your app so that the common view appears only in detailViewController part so that it will appear in portrait mode also.
If this is not feasible, the only option you are left with is to create your own splitViewController, so that you will be capable of adding it over some other views and send the rotation events to this splitViewController when rotation occurs.

Resources