In Xcode, why are there more/less views depending on what device is running in the simulator? - ios

I am having an issue where aspect fill is working on iPhones, but doesn't work on iPads except for iPad 7th generation. In the process of debugging, when I looked at the "Debug View Hierarchy", I noticed that some devices had a WindowView and a UIView behind my UIImageView while others had more views such as UITransitionView, UIDropShaddowView, and one had 2 UIViews. Why is that and why is it not consistent on all devices? Thank you.

I don't know how your app is built up, but different UIKit controls can result in very different view hierarchies depending on the display size of your app. For example a UISplitViewController might end up being a simple navigation view stack (with much less views involved) on iPhone in portrait vs. an actual split view controller on iPad.
View hierarchies may also differ if you're running different OS versions across your devices, simply because implementation details of the system frameworks changed.

Related

Turn off split view for iPhone (all sizes), but retain split view for iPad

1.) We have a universal iOS app that incorporates split view and slide-over for iPad. Just right. For iPhone, on the other hand, we do not want to use these features.
2.) Split view does not appear for smaller iPhones, even in landscape, which is the desired behavior. Just right, again. However, larger iPhones in landscape mode do by default, utilize split view, which is not the desired behavior.
3.) Split view on larger iPhones can be disabled at the user level(iOS 14): settings -> display and brightness -> view and select "Zoom". That does achieve the intended result. However, user may not find that feature desirable for all of their apps across their device. It also requires a certain level of user sophistication to figure this out. For these reasons, that is not a viable solution.
4.) There is an info.plist option called UIRequiresFullScreen, which achieves the intended result for iPhone, however it also disables split screen and slide-over for iPad, which is not the intended result. We want this only to apply to iPhone. That is therefore not a viable solution either.
Seems there is likely a simple solution to the problem of turning off split view for larger iPhones for a universal iOS app, so the larger iPhones function just like the smaller iPhones. Thoughts?
Responder dfd helped steer our thinking back on the right track. The solution is not to try to remove the iPhone splitViewController feature of iOS, but as dfd pointed out, we should embrace the feature. Thinking in splitViewController mode, rather than trying to force the larger iPhone to be a smaller iPhone, the behavior we are looking for in landscape view on larger iPhones is:
splitViewController.preferredDisplayMode = .primaryHidden
Calling this preferredDisplayMode on rotation on iPhone provides just the solution we were looking for. Thanks to all who took the time to review our question!

Appropriate way to manage different views for portrait and landscape?

I'm developing an app targeting iOS 7 and above. I'm using storyboard and autolayout, and I have to show different layouts of each storyboard scene depending on the device orientation, I mean, for example: in portrait I may have a button at a certain place that has to be shown in another place in landscape, or I may have controls in portrait that should disappear in landscape and have to rearrange the rest of controls.
My question is: when there are a lot of differences between portrait and landscape, should it be better to manage all this changes by programmatically updating constraints, or should it be better to create different nib files and load the corresponding according to the orientation?
use size classes their will be no problem in giving support to ios7 . I have tested their were no major problems in ios7 while using size classes.

Fit an iOS application developed for 4 inch screen to 3.5 inch screen

I am writing my first iOS app and just realized a serious problem. I was using storyboard for a 4 inch iphone screen and forgot to take 3.5 inch screens into consideration. :( It seems that this could be relatively fixed easily if I have done everything in code. But unfortunately, I have used storyboard for some parts of my app. It seems that the table views are fit perfectly but the views with some fixed subviews fail. Could anyone please give me some suggestions on how to fix this? Any help is appreciated. Thank you very much!
This is exactly what auto layout exists for. You can create a UI, using storyboards, that works perfectly for both screen sizes. You can toggle a setting in the storyboard to have it display the two different screen sizes, so you can easily see how your views will move and resize. There is also a preview mode for the storyboard that lets you see how it will look. It also lets you see how it will look on both iOS 6 and iOS 7, so that you can make sure that your UI looks good on both assuming you still support iOS 6.
If you had done this in code, it would probably have been a whole lot more complicated, especially since you have to run it each time to see what changes when you adjust your code. Graphical layout tools such as Interface Builder (what allows you to view and edit storyboards and XIB files) make supporting multiple screen sizes very easy. Plus, generally it's not too hard to make a screen designed for a 4" screen work with a 3.5" screen, in some cases you just have to make things fit a little closer together, or perhaps have the content in a scroll view.

How/whether to make a universal storyboard in Xcode

When creating a storyboard file in Xcode, you must select if it is for iPhone or iPad. This implies one should always put iPhone and iPad UIs into separate storyboards. Is this true?
My app has multiple storyboards. While the Main.storyboard files largely differ between iPhone and iPad, other storyboards are nearly identical. The only difference might be segue being a push on iPhone vs popover on iPad, which can be handled programmatically. It seems awfully silly and redundant to make two storyboards.
So if making one "universal" storyboard, should iPhone or iPad be selected in Xcode? Does it matter?
As of Xcode 6, we can create a single unified storyboard for all the devices.
For more info - Documentation
iOS 8 makes dealing with screen size and orientation much more
versatile. It is easier than ever to create a single interface for
your app that works well on both iPad and iPhone, adjusting to
orientation changes and different screen sizes as needed. Design apps
with a common interface and then customize them for different size
classes. Adapt your user interface to the strengths of each form
factor. You no longer need to create a specific iPad storyboard;
instead target the appropriate size classes and tune your interface
for the best experience.
There are two types of size classes in iOS 8: regular and compact. A
regular size class denotes either a large amount of screen space, such
as on an iPad, or a commonly adopted paradigm that provides the
illusion of a large amount of screen space, such as scrolling on an
iPhone. Every device is defined by a size class, both vertically and
horizontally. iPad size classes shows the native size classes for the
iPad. With the amount of screen space available, the iPad has a
regular size class in the vertical and horizontal directions in both
portrait and landscape orientations.
Edit:
It only supports iOS 8(backward compatible applies only for iOS 7) and later.
You've got to create to separate storyboards for each kind of device. If you would delete the iPad storyboard, than your app would use the iPhone's one. You'll realize it when you'll see the 2x button at the bottom of the screen. Everything will be scaled to fit the larger screen - and the graphics would be really bad.
The only suitable workaround is to copy-paste everything from your iPhone Storyboard to iPad storyboard. Just follow the next steps:
Open iPhone.storyboard,
Press CMD+A,
Press CMD+C,
Switch to iPad.storyboard,
Press CMD+V,
You'll see, that all the screens, segues, properties and actions are transferred to your new storyboard. All that you have to do is to fix the frames of all your elements so that they'll suit new screen sizes.
And don't forget, that a good iPad application shouldn't be the same as the iPhone version. There are a lot of cool things which you can do with iPad!

iOS storyboard layout

I am working on an app and have come into some graphical problems when designing my app.
First off, my app is only support by iPhone. My current storyboard is using the iPhone 5 as the screen size, so everything screws up when I try to run in iPhone 4 and 4S. Is there a way to make multiple storyboards for each different screen size? Or do you all have another solution?
Thanks!
- Brad
There is a way to make different storyboards for separate screen sizes, but another way to do it is like this:
Whenever you add objects to your views, be sure to have them aligned to something (using constraints). If all items are relative to other items, then most likely the layout will be fine on all devices. Also, if you find that your controls start overlapping, then perhaps you ran out of room. In that case simply add a scroll view to your layout, and then put the controls on top of it. Then, it won't scroll on the larger screens because all controls are shown, but on smaller devices it will allow you to scroll down to see the rest of the objects.
Good luck.
There is a small button in the lower right hand corner that lets you toggle between 3.5" and 4" screen sizes so you can see how it will look on different devices. By using Auto Layout introduced in iOS 6 you can make sure to set up your constraints so that your UI looks good on both older and newer iPhones.

Resources