I have just run into a problem regarding how my app launches. Even though I have selected launch from portrait my app always launches in landscape view and I have to rotate my iPod to make it switch to portrait.I have been mainly working in the storyboard section of my app and don't have much code at this point. Do I need to enter some code to launch from portrait? Thanks, I am a beginner and am very grateful for any help.
Make sure you follow these 3 steps:
1) On the .plist file make sure landscape is listed as one of the supported orientations.
2) On the viewcontroller for that view make sure that your code returns yes for the should autorotate...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
3) On the IB select your initial view and then on the fourth tab from the property inspector, under the simulated metrics make sure that Orientation Landscape is selected.
Related
New iOS requirements need Apps for iPhone or iPad must be built with the iOS 13 SDK or later and use an Xcode storyboard to provide the app’s launch screen.
But my project is very old and has never used Storyboards. All UI elements are created dynamically using ViewControllers.
I managed to create a storyboard file and set it as a launcher but it has no scenes and I do not know how to proceed. I would like to:
Create a scene where I place only the original launch image inside (hoping that apple still accepts this branding)
If it is possible to just connect my main ViewController with the scene (if that works with dynamical ViewControllers)
If nothing helps than I would need to create a simple scene which has just a bottom bar like my ViewController
I had this exact issue, here's what I did:
Create LaunchScreen.storyboard and set to use it as launch screen
Using the + button in the top-right (this was not an obvious step), add a View Controller into the storyboard
Untick "Use Safe Area Layout Guides" on the right panel if you're getting that error
Tick "Is Initial View Controller"
Then clean and run, for me it just worked. I did have trouble seeing it update though, as discussed here: Launch Screen storyboard not displaying image
On a test drive app, I have a basic UIViewController (QZTestViewController) loaded with its xib file with only one UILabel centered by autolayout. This controller is opened from the home controller (QZHomeViewController designed in the default storyboard).
The problem is that the height of this label is smaller that the result on the simulator. See it in XIB/Simulator comparison snapshot.
Any idea ? A small test project is available here if someone can have a look and help me before I become crazy.
PS: Note that the simulated metrics is set to iPhone 5.5-inch in the XIB file and I run the simulator iPhone 6s Plus (9.3).
From the size of the status bar items on the Simulator (and double-checking your project), I can tell that your app is being upscaled to fit the screen. This is happening because it's not properly configured to the 4.7" or 5.5" screens.
To fix that and make it load with the correct resolution, simply add a LaunchScreen storyboard to your project. Go to your project settings, select your Target and in App Icons and Launch Images select a storyboard or xib file to Launch Screen File. This will make the app compatible with the larger screens' resolutions, and your button will have the correct size as it will not be upscaled :)
I have a Universal application in Swift 2.0 developed in XCode 7.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
When I run the application on my device (iPhone 5s), none of the labels are aligned and the toolbar is out of view. -This is also the case when I run using the iPad device in XCodes simulator.
Image of what the view controller contains ...
From the snippet above, when I run this VC on my iPhone there is no margin on the right side, and the toolbar is cropped off.
Can anyone advise how I can make a universal application show all the content in the VC, on all devices. Or how I would simply show the toolbar ...
That's what auto layout (constraints) is for.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
That's irrelevant, and indeed misleading, since in means that only on the iPhone 4.7-inch will your app look like the storyboard design — unless you use auto layout.
iPhones come in many screen sizes. Basically, you have no way of knowing, as you design, what the screen size will actually be! Auto layout is the solution. Auto layout allows your interface elements to adjust automatically as the app launches on a particular size screen. iPads can serve as an extension of this — i.e., just an even larger size screen — or you can even use conditional constraints to make the interface quite different on the iPad from the iPhone, if desired - all designed in a single storyboard.
Maybe you are using auto layout and auto constraint. You could deactivate this in opening the storyboard, open up right panel , go to "show the file inspector" section and under Interface Builder Document uncheck auto layout and auto constraint
Image here
Select your item view, go into "Show the size inspector" and there you can set your autoresizing for all devices
Apple recommends to use a single storyboard for universal apps through size classes.
Now I am trying to adapt the UI depending on the device, which has worked quiet well so far. The only problem I'm facing is how to assign the specific segues.
For instance the settings, which in my App consist of only two tableview cells, should be made visible via a "present as a popover" on the iPad and a regular "show (e.g. Push)" segue on the iPhone.
Is there any way to define it just like that using storyboards or do I need to write supporting code?
Nick
In WWDC session Apple engineer used "Present as popover" segue.
This one shows view modally on iPhone and popover on iPad. Though, you'll have to write some code to show Back button on iPhone.
If you need to have popover and push segues, I'd do that in code this way:
Make 2 segues 'Present as popover' and 'Show'
Set up segue identifiers
In code identify whether app running on iPhone or iPad
Launch correct segue
so, i have an ios app and i have built it with interface builder and xcode. I built it using interface builder in the horizontal view because that is how i want my app. I have also made the supported views landscape left and right and i have edited info.plist to make it open horizontally.
But when i build and go it opens in iphone simulator horizontally but it shows as it would if it was vertical.
here's some screenshots:
what i want it to look like:
http://www.sendspace.com/file/4ct4b0
what it actually looks like:
http://www.sendspace.com/file/fayjqj
how could i get it to open like i want??
You have to allow the orientation also in your implementation of UIViewController using shouldAutorotateToInterfaceOrientation :
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return YES; //or UIInterfaceOrientationIsLandscape(interfaceOrientation) for just landscape
}
Also, if you have some more problems look on linked SO questions to this "out-dated" question:
iPhone app in landscape mode, 2008 systems