All custom UITableViewCells which are compiled under iOS11 (Xcode 9) are getting an extra leading margin but not with iOS10 (Xcode 8). Please see the images.
iOS 10, compiled with Xcode 8
iOS 11, compiled with Xcode 9
How to get the iOS 10 behavior for devices with iOS 11 too.
I was able to solve this problem using the answer to UITableViewCell with autolayout left margin different on iPhone and iPad. Setting “Preserve Superview Margins” on both the table view cell and the content view it contains resolved the inconsistency between rendering in iOS 10 and iOS 11.
Another workaround, in the opposite direction (i.e. having the same behaviour you had in iOS 10), would be to set preservesSuperviewLayoutMargins to false in the cell and the content view of your cell. For example, in you UITableViewCell subclass:
override func awakeFromNib() {
super.awakeFromNib()
preservesSuperviewLayoutMargins = false
contentView.preservesSuperviewLayoutMargins = false
}
This way you recover the iOS 10 behaviour.
Related
There is a change in UITableView layout after upgrading to iOS 12 from iOS 11. Please find below images for reference:
iOS 11 look and feel for UITableview:
iOS 12 look and feel for UITableview:
On comparing two above images, there is a absence of extra space from left and right of UITableView in iOS 12.
I want to have same look and feel as iOS 11 for UITableView in iOS 12 as well.
Need some suggestion for the mentioned issue. I am using Xcode 10 and upgraded code to SWIFT 4.2.
I am able to figure out the root cause and a solution for the issue.
There is a property for UITableView - "cellLayoutMarginsFollowReadableWidth" which is "true" by default in iOS 11. In iOS 12 the default value for the property is "false"
Setting the property value to "true" solved the issue.
Please find the below code as reference :
tableView.cellLayoutMarginsFollowReadableWidth = true
Use tableView.separatorInset = .zero to manually adjust the separators to hug the edges.
I have been using a UITableViewController in my app. It worked fine in iOS 10.x.x but I recently upgraded my Xcode and iOS to (Xcode 9 and iOS 11). Then the my app is having this UI issue. It will show a 20 points gap above the UITableView in a UITableViewController with static cells. Anyone having same problem and found the solution for this?
It is due to the new property introduced in iOS 11. Try the following:
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
chengsam's answer works perfectly to solve this problem.
If you want to accomplish the iOS 11 part in Interface Builder, you can do so. It's available in the Size Selector in the Utilities View.
For example: I have set in a storyboard scene a vertical space constraint from de bottom of a UIButton to the bottom of the superview with a constant of 20. When running in an iOS 8 device, this is correctly shown, but when running in an iOS 7 device, it looks like this constant becomes higher and the button is shown upper in the screen... I don't understand why this happens, since autolayout is supposed to be available since iOS 7.
Any help? I don`t know how to handle this.
Thanks in advance
One of new things in iOS 8 is the Layout Margin. Layout Margin is a new property available in UIView for iOS 8. So, any objects inherit from UIView will have this property. If you are developing the app for both iOS 7 and iOS 8, you should not use Layout Margin (or use layout margin in a smart way).
So, if you have any constraints related to layout margin and you didn’t do a proper check before launching the app on iOS 7 devices, the app might crash or the arrangement of the objects might be out of order.
Whenever you are trying to add new constraints from the storyboard in XCode 6, “Constrain to Margins” is ticked by default. The meaning of this selection is to add constraints with the new property in iOS 8.
If the deployment target of your app is iOS 7 and above and any of your constraints have this layout margin, the XCode will complain with the warning “Layout attributes relative to the layout margin on iOS prior to 8.0″.
If you are developing the app for both iOS 7 and 8, it is best to “Untick” the Constrain to Margins.
Reference: you should also check this great tutorial
I want to resize the height of a UITableViewCell moving down cells below it, I don't know how to do that using Autolayout in iOS 7 or iOS 8. Can anyone help me?, please
I have used the Autolayout in iOS 7 and it works correctly without any problems but regarding to iOS8 it isn't worked at all .
Can i used the same UITableViewCell constraint for iOS7 and iOS 8 ?
I have experienced, that on iOS 8 some things just don't work as they did in iOS 7. For example, I had a Tableview with a few custom cells. Everything worked fine in the iOS 8 simulator, but on a iOS 7 device the tableview was always empty and the cellForRowAtIndexPath function was never called. It turned out to be a problem with Autolayout. Everything I had to do was to set correct constraints for the whole tableview, not just the cells. So my advice would be to check ALL constraints used in your view, not just the ones you think could be messed up.