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.
Related
This problem occurs depending on the language setting of iPhone.
I was able to confirm this problem in Japanese and Chinese.
In English etc. this problem does not occur.
I have created a simple project that installing UINavigationController on the storyboard, using Xcode10. rootViewController is the default UITableViewController.
I have not changed anything nearly anything on the storyboard.
I use an array of Strings 1 to 5 as datasource of UITableView.
If I build and rotate this on iOS12, UITableView will be plus offset top or it will be under NavigationBar.
This problem does not occur in iOS11. Also, no problems will occur in models without notch.
This problem occurs only with notched models of iOS12. (iPhone X, XS, XS Max, Xr)
Does anyone know the cause of this strange problem?
Thank you.
I uploaded my project to GitHub. Could you confirm it?
yaslam2222/SimpleTableViewController
I think you've found a bug! (As you have rightly explained, this happens only on an X device, only in iOS 12, and only in a Chinese or Japanese environment.)
Here is a workaround — not very satisfactory, but at least it is a workaround:
override func viewDidLoad() {
super.viewDidLoad()
self.edgesForExtendedLayout = []
}
I reported this bug to Apple. Apple responded that it shall be fixed on iOS 12.1.
I installed Xcode 10.1 beta 2 and confirmed this bug on iOS 12.1 simulator.
I confirmed that this bug has been fixed on iOS 12.1 (simulator).
Thank you.
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 build an table that can choose multiple cells.
But when run it in iPhone 8 Plus simulator, the cells are often unable to click, then I should return to previous page and go back to the table, make it work(usually should return and go back several times).
But sometime it does work normally.
iPhone X simulator also has this problem, but seems not so frequently.
Pic of the table view
What's the cause and solution? Thanks
ios Version? try ios 10
if (#available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
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.
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.