Autolayout Causes UIScrollView To Not Work on iPhone 5/5s - uiscrollview

Whenever I launch my app on the iPhone 5/5s the UIScrollview does not work and part of the content is cut off, UNLESS I delete the following constraints:
However, if I delete these constraints, the content is not correctly aligned on the iPhone 6/6 Plus.
It does however have a little bit of a scroll when I launch it on the iPhone 4s.
How do I fix to have scroll working on iPhone 5/5s/4s but still keep the content the same across every iPhone? thanks
Here is my tree incase

FIXED: Changed the Vertical Space Constraint constant to 0.

Related

Search Bar and button placed improperly in landscape view despite constraints

I'm trying to add constraints to my button and search bar elements and they work fine in Portrait mode on multiple platforms including ipad, but as soon as I change to landscape view everything brakes and constraints showing conflicts on Iphone's only. Interesting is the fact that Landscape mode on Ipads is completely fine, and works as I imagine it to. I'm new and learning so might have overlooked something, does anyone have any ideas why this weird behavior?
Project has no fancy structure, just pulled up a default single page template on visual studio and dropped a button and SearchBar.
Adding a gif below with the storyboard I'm working on:
Cause:
Let's take iPhone 8 as an example:
The size of iPhone 8 is 375 × 667. In your case, in Portrait mode, you set your button vertical spacing to top equals 200. And you set your button vertical spacing to bottom equals 200. It's ok because the is still enough space for button(button's height is 667-200-200 = 267).
While in Landscape mode, you will found there is no enough space for button.(375-200-200 = -25). So you get conflicts.
Landscape mode on Ipads is completely fine, and works as I imagine it
to.
This is probably caused by the height of Ipads is enough to support the constraints as we know iPad is bigger than iPhone.
Solution:
Pay attention to the cause I mentioned above. You can also specify the size of button.

UITableviewcell width not filling the screen

I don't know if this is a bug with AutoLayout or Xcode but I've realised that if I run my application on a device which isn't the same size as the device in my storyboard, the elements are adopting the incorrect size.
I.e. Selecting View as iPhone SE and running the application on an iPhone 7+ The size of my tableview is the width of an iPhone SE screen, this fixes itself when I reload the view and then it then adopts the width of the iPhone 7+ screen.
Just a note as well the table view doesn't have a fixed width and is pinned to the top, bottom, left and right with 0 spacing and also I'm changing the height of the cells programmatically in code if this could affect it at all as well.
Video: https://drive.google.com/open?id=0B0QLbDLfJn6_YzljUGg4RTUwaTg
Views that come from a xib (or storyboard) have their IB frame values when they are created, before they are added to the view hierarchy. So a case like you describe is probably that something is accessing a view loaded from a xib before it has become part of the layout process and resized.
This would also explain why it's fixed when you go away and come back. The first time, it got the values before they were final, but the second time the values are already final and correct.
Layout code called fromviewDidLoad() for view controllers, or awakeFromNib() or initWith(coder:) for views is the likely cause. Layout code called from viewDidLoad() is especially problematic because it was fine up to iPhone 5s, but would now cause this problem.
It's impossible to say what exactly the issue just from this. From the NSLog statements visible in the video, the issue is whatever code calls that "weather view width". That is being called too early in the layout process. It needs to go in viewWillAppear or viewWillLayoutSubviews to make sure the correct values are ready for whatever calculation is dependent on that. Hope this helps.
I can't seem to recreate this. I would recommend double checking for any updates for Xcode and the Developer tools (softwareupdate --install -a).
Incase you haven't, restart Xcode.
EDIT: Disregard this answer, please read Mike Sand's post.
Try self.view.layoutIfNeeded in viewDidLoad or in viewWillAppear

Modal segues in xcode

When I run the application on Xcode an error appears saying "Modal segues are deprecated in iOS 8.0 and later". When I get to the simulator everything appears very large even after I reduce the scale to 50%.
There seems to be two questions here.
1) Why are Modal Segues deprecated in iOS8 and should I be concerned?
and
2) Everything is big in the simulator.
Modal Segues are replaced with adaptive segues in iOS8. The View Controller Programming Guide has information on the replacements, such as the "Show" segue and the "Show Detail" segue. The idea is that you can use one storyboard to describe an interface that works well on iPhones with small (4S, 5) screens as well as larger screens (6, 6+) and even iPads. To make efficient use of larger screens, it's now possible to have split views on iPhone in iOS8, and the new segue types let you specify that the next view should be shown in the detail area of a split view, or in the current view controller's area (aka its "context").
Traditional modal segues will continue to work, but they are not the preferred approach any longer, and as with all deprecated API, there is a possibility that a future release of the OS may remove those deprecated features. Consider revising your app to use the new approach. There are some WWDC videos, #214 and #218 at https://developer.apple.com/videos/wwdc/2014/ that are worth a watch if you want to get up to speed in a couple hours.
As for things being bigger in the simulator, it sounds like you're using the iPhone 6+ simulator, which is not only larger but also has 3X the pixels of a traditional iPhone non-retina. It will be larger when you run it, so you might want to drop it down to a smaller size like 50 or 25%. As an extra tip, those "change the size" shortcuts are Command+1, COmmand+2 and Command+3, so it's pretty easy to shuffle the size around. Alternatively, use another simulator, like the 5S Simulator.

App display does not fill iPad screen

I'm converting an app that I made for iPhone to be used on iPad. Using constraints on the Xcode 6 storyboard is killing me right now.
With my rep score I can't post an image of what I'm getting, but basically even when I set the constraints and the placement of the object (a UIView) on a storyboard sized for iPad, all the objects on the viewController fill only the top/left area of the screen.
What's the best way to handle this?
-- when you change size of view, other view will be auto change to {0,0,0,0}, isn't ?
but it doesn't change in the right panel.
it is your storeboard files some settings have some wrong.
Demo test link http://www.cocoachina.com/bbs/job.php?action=download&aid=80409
Check for those points:
hope this can help you.

Text starting at wrong position in textview in Xcode 6

There's no code involved at the moment, only storyboard or xib files as far as the textview is concerned. This is what I get when running the app on my iPhone 5s or via the simulator.
I'm using auto layout and size classes with the option any width-any height. An imageview at the top, then a label, then the textview.
Here's a picture of the screen. As you can see, it looks as if the text is starting behind the label, but the textview's y is after the label and the constraints seem all correct according to Xcode 6. It works fine on iPad.
Any idea of what I'm doing wrong?
I've found a way round it: textview should have no scrolling enabled and should be put in a scrollview instead, which will do the actual scrolling. Need to add constraints to both.

Resources