When the device is in portrait mode, I want to show text details about a graph, and when the user rotates it, I want my UIWebView to take up the full screen. This functionality can be seen in the iOS Stock app. When you are portrait, you can view all your stocks, and when the app is landscape, the full size graph is shown. How do i do this?
In your UIViewController sub-class override willRotateToInterfaceOrientation: to replace the view contents with the view contents for the appropriate destination orientation. I'd suggest using [UIView transitionFromView:toView:...] for smoother animations.
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.
How do I allow one subview of my view controller to autorotate on an orientation change, but keep the others static. I'm trying to get an effect similar to the native camera app where the capture and switch cameras buttons (along with all the others) stay in their locations and just rotate accordingly. The SnapChat app also does this where the UI layer that pops up after you take a photo autorotates but the other views do not.
I seemed to be able to get close following the answers here: Disable autorotate on a single subview in iOS8, however, while this prevents them from rotating, it jumbles up their positions.
I think you have to use
(i) autolayout to set constraints on view by fixing its position or width height.
for setting orientation for portrait and landscape you have to use size classes
(ii) Another trick is you can use UIViewController to fix orientation using its mask orientation delegate. then add it add child of other UIViewController
How to setup just one landscape view for whole app? I want to show only one view (qrcode) when phone is rotated independently in wich view this happened. What is the easiest way to do it?
My app is in portrait and I want show users code when it rotated to landscape in whatever view this was done.
See this answer. Just untick Portrait and tick on whatever Landscape orientation you want.
http://stackoverflow.com/a/29791531/7198143
Edit:
You should use Autolayout in your Storyboard to set up the right constraints so even in Landscape mode, the label for the code shows up. See this tutorial for more info.
Autolayout tutorial
I have an app in which its my intention to change screen orientation as the user rotates the iPad. In my app I have several popovers.
The potential issue I'm concerned about is one of my popovers covers most the screen so if rotation changes, I'd want the popover to change view dimensions. Is it possible whilst a view is open or will i have to close it and reopen it.
Thanks
If your using a UIPopoverController the standard behaviour it does is to hide the popover when you rotate. It try's to then reposition it for you, this tends not to work so you want to use popoverController:willRepositionPopoverToRect:inView to set your new position and resize as needed.
If you use setPopoverContentSize:animated: it will re size for you, If your using autolayout you'll want to use preferredContentSize in the content viewController.
Apple Doc:
If the user rotates the device while a popover is visible, the popover
controller hides the popover and then shows it again at the end of the
rotation. The popover controller attempts to position the popover
appropriately for you but you can also implement the
popoverController:willRepositionPopoverToRect:inView: method in the
popover delegate to specify a new position.
I'm making an application for iPad in Xcode in template Master-detail application. I need to do a design for portrait mode and another for landscape mode. My first idea was make two UIViews and make a rule: if portrait, show View1, if landscape, show View2. But I have text fields in it and when the user will be typing something inside and then rotate the device, text will be deleted, because it will be another UIView... Can anybody help me, how to do it, please?
You can have one view and use springs and struts or use autolayout.
You can also add views and hide/show them based on the orientation change.
You can change the size and position of the view on orientation change.