Broken cell with an odd strikethrough?

╄→尐↘猪︶ㄣ 提交于 2020-01-15 11:25:09

问题


I'm having a weird issue with a particular UITableView in my iPhone devel experience here. If you look at the following screenshot:

alt text http://dl-client.getdropbox.com/u/57676/brokencell.png

you'll notice a strike through going through the middle of the 'Jane Aba' cell.

Any idea what might be causing this odd graphic display? It's true for both the simulator and for the actual device running 2.2 SDK.

As requested, here's my -tableView:cellForRowIndexPath: method:

* EDIT *

I've located the problem. I'm not entirely sure why this is the problem, but it is. In my RootViewController, I have the following line of code in my -initWithCoder: method:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

When I comment that out, the cell (which is not in the RootViewController, but a secondary controller) it's resolved. Any idea why this might be the case?


回答1:


I've had a similar problem. For me, the single line was caused by a superfluous view that was created but never sized or placed correctly and so was 1 pixel high, floating over everything else. You can also cause this by confusing a UINavigationController about its set of subviews (by adding views directly to its layout container).

Look through your UI (xib files and programmatically created views) for a view that shouldn't be there or is otherwise not being used. It might be helpful to write some code to dump a UI Hierarchy, so you can see what views are where.




回答2:


Are you doing anything special in your -tableView:heightForRowAtIndexPath: method?

It looks to me like the height of the row is being set incorrectly, so the contents of the cell are expanding outside of its bounds.




回答3:


The problem disappears when you set the cell height for the table view to 1 pixel in IB. It seems that before you populate the table, an empty table is drawn with the outlines of the cell height set in IB. Don't set the cell height to 0. IB doesn't like that. :-)



来源:https://stackoverflow.com/questions/321522/broken-cell-with-an-odd-strikethrough

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!