UITableView separators disappears? - iphone

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.

Related

UISegmentedControl Not Redrawn

I'm using a UISegmentedControl to show headers for a table view. When the orientation changes, the headers are resized depending on the labels in the table view underneath. Despite being connected up in IB, I have to move the phone around a bit to fire a orientationChanged notification and update the widths. I've even tried setting the first segment width to 0 in IB, then again in viewDidLoad, but all headers are the same width when the view loads. I've tried using performSelector:afterDelay to make sure the view is actually on screen, and also calling setNeedsLayout and setNeedsDisplay, but nothing seems to work. I simply have to jiggle the phone around.
Is this a bug anyone has experience with or am I making a daft mistake?
I'm setting the width as below:
[segSortOrder setWidth:0.0 forSegmentAtIndex:0];
The only solution I came up with for this was to use performSelector:afterDelay and using self.view.bounds.size.width with a variable amount of padding (how much is trial and error for each ViewController. Not ideal but it does the job.

UITableViewCell subview not displaying until redraw

This problem is driving me nuts.
I have a prototype UITableViewCell in my storyboard. It contains a bunch of subviews. One of the subviews, a UILabel, is misbehaving.
When the tableview loads and is displayed for the first time, all of the cells look fine. However, as the tableview scrolls down, eventually one of the cells shows up without the UILabel subview. It seems that it is always the first cell that is being recycled.
If I continue scrolling down the tableview, however, as soon as the misbehaving cell is clipped by the top of the tableview (when it begins to be scrolled off the top of the screen), the label appears just as it should.
So it seems that the label is there, and it receives the string that I assign to it in my cellForRowAtIndexPath method. It's just not getting drawn for some reason. I've tried inserting setNeedsDisplay messages in various places, but that hasn't helped.
What is also strange is that I'm using the very same UITableViewCell subclass with a duplicate view hierarchy in the storyboard in a different view controller, and there I don't have any trouble.
Anybody have some idea of how I can start to unravel this mystery?
Thanks!
It sounds like it's only a problem when you use a reusable cell, which means that the values on reusable cells may not be getting set until you're ready to scroll off.

Delete confirmation moves images in UITableViewCell, but nothing else

I have a subclassed UITableViewCell that adds an image to the contentView, as well as two custom UILabels. When the table goes into editing mode everything shifts to the right correctly, but if I click on the delete control it nudges the frame of the image (which uses its own variable 'thumbnail') to the left. The labels stay in place, even though they're also subviews of contentView - so the image frame is being redrawn and contentView and the label frames are not.
I've tried overriding layoutSubviews but that doesn't seem to help, or I'm not doing it in the right way.
Does anyone know how to ensure contentView is treated as a single object, and prevent its individual subviews being moved? I'm not using IB and would prefer to keep it that way.
Thanks!

Mysterious rounded line appears at top of custom UITableViewCell

I have a mysterious problem with a custom subclass of UITableViewCell. The cell subclass is doing some relatively complex layout of UIControl instances, and then storing its height (based on the layout of those controls) in an ivar. I am performing zero custom drawing (I'm not overriding drawRect: at all).
For some reason, there is this strange rounded-corner-looking thing drawing at the top of the cell no matter what the height. I'm not changing the height of the cell's frame itself or anything; I'm just using tableView:heightForRowAtIndexPath:indexPath in my table view delegate. Everything else about the cell renders fineā€”it's just this one strange part.
Has anyone ever seen anything like this happen before? I am using iOS 4.2.
Turns out you have to call [super layoutSubviews] in your subclass' layoutSubviews method even though Apple's API docs say that the default implementation does nothing. Doing this fixed this problem (as well as turning off all autoresizing of subviews).

Broken cell with an odd strikethrough?

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