Broken cell with an odd strikethrough? - iphone

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?

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.

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.

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. :-)

Related

Extra space above prototype cell. Swift 3

If you look at the screenshot below of my table view theres a big gap between the prototype cell and the top of the table. Ive tried to re-size it but it just resizes the whole thing. Does anyone know how to make the prototype cell closer to the top of the table view?
This seems to be some sort of a bug, but it is easily solved. Drag a UIView from the object library and add it above the TableView as I've done in the image below. The problem should resolve itself.

Self sizing cell makes views to stretch

I tried to make self-sizing cells. I got it to work but with some bug. Which I think is because of wrong constraits. So I kindly ask you if you could look them.
Problem is that after scrolling in tableview, all my views are going to stretch. I thought that it would happen because of not setting height constraint but it seems not to be problem.
Illustration(pretty normal):
After scrolling and coming back up:
And these are my constraints for this view which all of them looks good to me:
And if you want to know how I made cells to resize, then like this:
tableView.estimatedRowHeight = 105//Because my row height is 105
tableView.rowHeight = UITableViewAutomaticDimension
When this sort of thing happens, the implication is that you are not supplying sufficient constraints to size the cell's contentView from the inside out. You can readily confirm this using View Debugging to pause the app when you see your incorrectly sized cell; you will then be able to study the actual values of your constraints and see what the problem is.
EDIT Now that you've posted your constraints, it's easy to see what the problem is: There is nothing at all connecting your interface elements to the bottom of the contentView. But that is the whole point of self-sizing cells: you must have, as I already said, sufficient constraints running all the way from the top of the contentView to the bottom of the contentView. That is what determines the height — and so you are not determining it.

UITableView separators disappears?

in my uitableview, i subclassed uitableviewcell's, and i added a subview to the contentview with flexible width and height. the cells are of dynamic height.
when the tableview first loads, everything is fine. however, as i start to scroll around, separators start disappearing, and they happen at the same places every launch. scrolling around some more will recover the lost separators.
anyone else encounter this?
I don't know how specific this will be to your project, but I'll tell you what I figured out. Overriding my layoutSubviews method was the problem. I looked at the view hierarchy of my cell before and after I called [super layoutSubviews] and discovered that this method was making the contentView 1 pixel shorter and added a new view below it 1 pixel high with a background color of 0.88/0.88/0.88.
If you can't live with some of the side effects of the superclass implementation, it looks like this view must be added manually.
The problem was related to the dynamic heights. Using either ceilf or floorf solved the problem.

implementation of collapsing tableView Cells

so I wanted to have a table with multiple sections and each one with multiple cells. By touching a section's header, this section should expand and the others should minimize, leaving only the header visible.
I looked up some suggestions and accomplished this by a) setting the cell's height to 0 and reloding the data animated and b) adding a button as a subview to the cell's header.
Anyway, while it works fine, mainly, there is minor problem, namely, I can see a 'flickering' below each cell's header, when the change is animated. I guess its because the cell's content is redrawn. And I don't like it!
I wanted to ask whether the approach is correct or generally your opinion about it. Moreover I would be really happy, if someone could hint me why the 'flickering' appears in my table :)
EDIT: Another thing is, that if I press on a section, it appears like all the section headers are pressed.... maybe someone has seen this weird artifact also?
You should remove cells instead of setting height to 0.
You will have less call to data source and delegate and no more artifacts.

UISegmentedControl not expanding size for navigation bar/very squished

Running through an iPhone SDK book and one of the examples has me creating a table and then later adding a UISegmentedControl to the table for sorting.
I dutifully did this in IB, and it looks great:
IB Screenshot http://img.skitch.com/20100529-83sefni21q4nj51rw1mghh2yj1.jpg
When I run it in the simulator or my phone, it's totally squished:
Squished http://img.skitch.com/20100529-x3pmr7gkb6xpm766bupi7quy55.jpg
The buttons work perfectly, it's just they are not sizing according to their content. Any ideas what's going wrong?
Here's the attributes I have set:
Attributes http://img.skitch.com/20100529-tp4d69bk8x98c6sjpmcne92etb.jpg
You could try explicitly setting the width of each of the segmented control's components. Click the Size tab at the top of the inspector and set the width for each component.
I experienced the same issue once. The problem was that the UINavigationController's view was not the top-level view in the hierarchy (it was not added to UIWindow directly), but it was added as a subview to another view controller's view instead. It's just a guess, maybe that's your problem, too (or that there are more than one visible view controllers).
OK, so in attempting to implement #Chris Gummer's answer, I seem to have learned more about how the Size->View Size property panel works. The default is:
Default Sizing http://img.skitch.com/20100529-gg9dwq5em3557yb1d6d721hpn4.jpg
and this is not a good default, it would seem. My book didn't mention needing to adjust this, so I didn't look at it. Setting the inner horizontal arrow of the box (which I guess means "fit width to available space") did the trick:
The Answer http://img.skitch.com/20100529-xt1bqghb4kbm2pbcqf1i1uygab.jpg