Posts

Post not yet marked as solved
0 Replies
1.3k Views
How can I make a UITableViewCell with custom style inset from the safe area of the device screen when it is part of the view hierarchy UINavigationController > UIViewController > UIView > UITableView > UITableViewCell? My UITableViewCell left side is getting cut off by the camera notch.Setting the iOS 11 contentInsetAdjustmentBehavior and insetsContentViewsToSafeAreamethods do not work when I have a combination of both custom layout UITableViewCell (not one of the Basic/Detail view styles) and am using the UITableViewCell in a view that is itself within a UINavigationController. And those values should default to YES.I've also tried setting preservesSuperviewLayoutMargins which defaults to NO.A couple of the behaviorsSetting the view hierarchy as UIViewController > UIView > UITableView > UITableViewCell. UIViewController is the entry point of the Storyboard. (below) The custom UITableViewCell is inset from the horizontal safe area correctly like normal.Setting the view hierarchy as UINavigationController > UIViewController > UIView > UITableView > UITableViewCell. UINavigationController is the entry point of the Storyboard with UIViewController as the root view controller to the navigation controller. Only the UITableView requires preservesSuperviewLayoutMargins = YES to inset the Basic/Detail style UITableViewCell from the safe area.Setting the view hierarchy as UINavigationController > UIViewController > UIView > UITableView > UITableViewCell. UINavigationController is the entry point of the Storyboard with UIViewController as the root view controller to the navigation controller. Unable to inset the default style UITableViewCell from the safe area.In the below screenshot the UITableView.preservesSuperviewLayoutMargins = YESwith a custom layout UITableViewCell but the cell fails to properly inset with safe area as seen in the cutoff simulator at the bottom.My layout constraints for the custom UITableViewCell are shown below. As seen Interface Builder simulates the correct inset but the actual simulator run does not inset the cell.The view hierarchies in #2 and #3 are the same with the only difference being the use of a custom layout UITableViewCell vs the default Basic/Detail style.I've tried setting preservesSuperviewLayoutMargins = YES on every view in the hierarchy and it makes not difference for getting the custom UITableViewCell to inset. I made a simple test project https://drive.google.com/file/d/1FJJ2f91pgm2QtBjlJMZZXoaPn2nSkOsX/view?usp=sharing demonstrating the inset issue between default Basic and custom style cells in the described view hierarchy.I can't be the only one testing a custom UITableViewCell on a landscape iPhone X/11. How can I get the table cell contents to inset correctly from the device safe area? Thanks.
Posted
by ansonl.
Last updated
.