I've been updating my app to so it can work in iOS 10, 11 and the new iPhone X. I don't use Storyboards, and I've noticed that when using the new safe area guides, everything works as expected on any device that runs iOS 11. However, in iOS 10, it seems that the safe area guides are not being converted to the previous layout guides.
Here's a simple example with just a view aligned to the top, left and right safe area margins:
This is what happens when using xib:
And with storyboard:
I have noticed that two people had similar enter link description here in enter link description here and in the Apple Forums but the solutions are hacky and are trying to fight the underlying framework. Is there any oficial solution to this?
Related
I am new to iOS platform but still been able to build my first app in the last 3 weeks. Coming from android, I was able to leverage of some of the knowledge I had to adapt quickly to swift and iOS but I struggle with auto-layout in the storyboard. I have not been able to get a flow that works.
I am currently using Xcode 11 and have tried to UIScrollView but to no uniformity. Whatever I arrange correctly on iPhone 11 deforms on iPhone 8 or lower.
I have watched different tutorials on youtube, lynda.com and pluralsight but to no avail.
What is the best possible way to use auto-layout across different screens like we have in android with constraint layout/relative layout?
I recommend using anchor constrains programmatically. Setting border relative to different items will provide autolayout in all devices. If you post a screenshot of your needs , it might be easier to provide accurate answer. Also keep in mind that superview borders in iphone 8 and lower version differ from borders in higher version according to the top notches. You need to set your views relative to safe area of the superview.
I've been facing an weird issue which I have never experienced before (pretty new to iOS). I am trying to develop a blog reader app and I am using a UITableView inside my main View. Within the TableView I have added 1 prototype cell and modified it's height to be somewhat bigger.
In order to create a "floating", "shadow" or "card" effect within the TableViewVell I have added another View which will contain a cover image and a summary.
The problem I am facing is related to the layout that is displayed by the Preview Assistant for Storybords.
Even though for iPhone 8 (xCode 9.1) everything looks fine based on the constraints that I have put in place, for iPhone SE and 8 Plus things look weirdly different even though during the simulation things do not really look as described.
I have watched WWDC Videos, YouTube Videos, even some great tutorials but none seem to go beyond the basics and actually cover this issue that I am facing.
Here is a screenshot:
XCode Storyboards Preview
I made a simplified demo ofthe project which can be checked out on GitHub:
https://github.com/sebastiannitu/ConstraintIssues
I would very much appreciated if seomeone would calrify this issue for me once and for all. I am sure it's just me doing something silly but I cannot really waste any more time with this. I've already invested about 2 weeks in trying to figure this out!
Thank you very much for your replies in advance!
It's a mild bug in Xcode, but no big deal. Do this:
Change the device type in the canvas, e.g. to iPhone SE.
Switch away to your code, e.g. ViewController.
Switch back to the storyboard. Notice that the constraints have now fixed themselves in the canvas!
Show the Preview for that device type.
So it's mildly annoying, but it does work. Here's the preview for the iPhone SE:
Here's the preview for the iPhone X:
your constraints setup is fine . problem is with only assistant editor. if you run it in your simulator, View (orange View) will resize currectly.
Here is the screenshot for orange View, when running in iPhone 8s (left) and iPhone 5s.
i am not uploading project, but if you have problem then let me know.
Now, before all you angry people say "hOLY DUCK THIS IS A DUPLICATE", just wait. I've seen at least 10 articles on this, NONE of which have been a help. My issue is im trying to make my iPhone app (xcode 8, swift 3.1, iOS 9 deployment)
match all screen sizes and set the app size to the NATIVE screen size on the device. I've seen the launchscreen articles, and they have been no help because they aren't specific. If somebody could either provide a tutorial or link one so I can figure this out, that would be great. Thanks all
You want to set the constraints for your views.
Here's a tutorial specifically for XCode 8:
https://www.appcoda.com/auto-layout-guide/
Here's another for Adaptive Layouts:
https://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started
At their most basic, constraints lock parts of the view to known areas (top, bottom, left, right) on the screen. Compounding constraints can be helpful for specific problems, but they get complicated quickly. If you're having problems getting them to work properly, I have found it works best to remove all of the constraints and start again with something simple and increase complexity as needed.
I could not figure out why this is happening.I searched here but could not find any answer for this.
The problem is I developed some screens using StoryBoard in xcode 4 and ios 6 but now I upgraded to xcode 5 and ios 7.But after upgrading all my labels,text fields have changed dimensions.Their x,y co-ordinates have changed along with width and height.They all have same x,y co-ordinates(0,758) and width,height as 0,0.
I can bring them back manually editing but there are too many fields to do so.
Is there anyway to do it easily?
Recommendation
From your problem description it sounds like you're seeing the effects of the deep system changes in iOS7.
To verify that you are not seeing any bugs please select your storyboard or xib file (this works on both) and open the assistant editor.
Next choose the Preview as the assistant editor. This will show you the storyboard layout as it will look on your device.
Note the menu on the lower right will show three things:
The version of iOS being previewed
A rotation control to show the controls in different orientations
A height control to show how the view will look at 3.5/4.0 heights
iOS7 Preview
iOS6 Preview
Please keep in mind that the iOS7 control sizes are different from all other prior versions of iOS so they will never line up precisely. Use of auto layout will need to be re-examined if your app is highly complex: There are two options: Review the auto layout guide (here) or turn it off (in the file attributes inspector) and use the old springs and struts (autosizing).
I recommend a thorough reading of Apple's transition guide (link) to make sure you understand the impact of the changes to the UI controls.
Techtopia has a good article on iOS7 Auto Layout which can be very useful in managing the sizing and appearance of UI Controls (link).
Apple has a sample app that I think is worth examining called UICatalog (link). I recommend downloading the app and running it on your simulator to see how the new controls will look. Note that the sample does not have auto layout constraints active, if you choose to continue using auto layout you may want to consider defining your layout with the Visual Formatting Language (link).
Other things to consider
There were some bugs with the early build of storyboard in Xcode 5
and auto layout was changed significantly, please make sure you
download the absolute latest version of Xcode.
You could try cut and paste the objects in Xcode.
You should verify that the auto layout setting is consistent between
versions (either on/off in the file inspector).
Check that your auto layout constraints are not generating a warning
or error in Xcode. If they are you will need to Update All
Constraints.
Make sure you have git turned on before starting so you can rollback
your changes to a known state.
Hope some of these suggestions will be helpful.
I am following the course on iOS through iTunes university and working on the calculator project. I moved the controls on the storyboard to make room for another control at the top. Everything looks fine on the storyboard but when run in the simulator, controls are bunch up, on top of each other, and some are clearly off the top of the simulator screen. This leads to the following very related questions.
How does one move controls around on the storyboard? I went to the size inspector of each control (buttons in my case) and changed the 'Y' value (increased it by 10). I did this for each control. I didn't think about it as I was doing it because as I said, all looks fine on the storyboard. Is there a better way to move controls around? I could not figure out how to grab more than one control at a time and move them. Grabbing all and moving or all but one and moving would have been ideal.
I anticipate someone is going to say, "We need more info. " How do I show the storyboard? Is there a xml file somewhere? How is the storyboard saved? How should I show the results of the simulator?
In general, what the heck is going on? Why would things look so different in the simulator?
Is there a better forum/group to ask newbie questions about iOS programming?
My specs are these:
XCode 4.5.2
Ios simulator versions set to 6.0 and iPhone
Any other info needed? Thanks in advance,
Dave
Try setting your simulated device size to 'freeform' instead of 'inferred'. This screen is a bit smaller so the controls are no longer overlapping. The latest xcode sets it by default to ios6 (screen size of iPhone 5)
edit For a better insight in xcode IDE, please refer to the documentation provided by apple (includes screenshots for clarity)
https://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/000-About_Xcode/about.html#//apple_ref/doc/uid/TP40010215