开发者

UITableView separator at wrong position

On selection I change the height of an UITableViewCell (loaded from a nib).

But the separator line is at a wrong position when I do this.

UITableView separator at wrong position

In the screenshot the first row is selected, and therefore bigger than the other ones.

From the separator positions it looks like the cell after the selected cell would be the big one. The second cell "has" exactly the size the first cell should have.

To change the height I save the selected indexpath in tableView:didSelectRowAtIndexPath: and compare it in tableView:heightForRowAtIndexPath:. If the indexpaths are the same I return the increased height. With the help of some NSLog I made sure that the correct height is returned.

And if I woul开发者_高级运维d resize the wrong cells the views of the cell would overlap, this doesn't happen.

If I click Line 3 of the first cell the tableView:didSelectRowAtIndexPath: fires and the indexpath is the one for the first cell. So I guess the heights are correct, and the tableview draws the separators on the wrong position.


Does anybody has an idea what I did wrong?

Any solutions? Or should I file another bug with apple?


Edit: If I don't reuse my cells it works as expected.


It turned out that I had switched off "Autoresize subviews" for the UITableViewCell.

If I turn that option on it works as expected.


I had a similar problem. In my case I was using layoutSubviews to do custom layout on my cell. The separator was in the wrong position and the layout of the accessory view was also out.

In my case the issue was failing to call [super layoutSubviews].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜