简体   繁体   中英

UITableView strange layout iOS8 - UITableViewCellSeperatorView

I have a strange problem where the separator lines crawl onto the cells. The same row height is specified both in interface builder for the table and the cells (68 pixels). Is this an autolayout problem? This did not happen in iOS7

在此处输入图片说明

This happens after refreshing the table: only the bottom cell is broken. Anyone know why? Don't mind the change in color- the screenshots were taken at different times.

在此处输入图片说明

EDIT:

This is a problem pertaining to the UITableViewCellSeperatorView not lining up with the height of the cell defined in interface builder as well as the row height defined through code and through interface builder.

Spent two days on this so I hope this helps you out.

related questions: When I set the rowHeight for UITableView, shouldn't the height of cell changed as well?
and UITableView separator strange behavior

After asking a lot of questions on freenode, maqr suggested it was an autolayout issue -- i checked for ambiguous constraints and there were none, using po [[UIWindow keyWindow] _autolayoutTrace]

Next I discovered that the gray line was the UITableViewCellSeparatorView using the view-hierarchy inspect tool in xcode 6.

Then I searched for how to fix this. The most straightforward way is to set the frame of your cell manually. This is crazy of course, but it works. Do it inside:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

Solution:

try setting the frame size of the UITableViewCell ie cell.frame = CGRectMake(0.0f, 0.0f, 320.0f, 32.0f)

Thanks to https://stackoverflow.com/users/593709/adil-soomro

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