简体   繁体   中英

UITableView inside UIViewControllerView unexpected margins

I have normal UIViewController on my storyboard with a standard UIView which contains only one child - UITableView

When adding constraints between UIView and UITableView ( equal widths, equla heights, vertical space 0 top layout guide, horizontal space 0 for leading margin ) as a result my table view should fill it's parent.

Instead my table view appears to have left and top margins (16 and 64). The Size Inspector shows that the table views Alignment Rectangle is as follows x=16,y=64,width=600,height=600 although all my constraints have constants set to 0's. When I try to edit manually Alignment Rectangle I keep getting Misplaced Views warnig which try to restore previous values.

Any I idea what might be the cause of this strange behaviour?

Click the view you want to remove margins. Open Contraint Editor uncheck Prefer Margin relative :

在此输入图像描述

I had a very similar problem. It was solved by deselecting Under Top Bars under Extend Edges in the properties of the topmost UIViewController in storyboard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM