I’m trying to narrow down a problem I’m having with 2 separate instances of UITableView within my iOS application. Maybe I set a bad property on the UITableViews or maybe it is something else, but here are the symptoms for both, as best as I can determine.
Both of the following bugs happen when a table is first created and loaded with data. But, if I then drag and release (thereby successfully scrolling the table, even a little), both bugs immediately disappear.
- I cannot tap on any of the rows (the delegate callback is never sent)
- No data appears (as if the table were empty)
Again, both of these bugs disappear immediately as soon as I try to drag on the table. I should also mention they do not happen 100% of the time. I’m guessing this might imply some sort of race condition that I’m missing.
The tables are programmatically instantiated subclasses (via initWithFrame:) of the UITableView. Here is my overridden constructor on the subclass:
- (id) init
{
if((self = [super initWithFrame:CGRectMake(0, 0, POST_WIDTH, 0)]))
{
self.scrollsToTop = YES;
self.dataSource = self;
self.delegate = self;
self.rowHeight = POST_DEFAULT_HEIGHT;
self.delaysContentTouches = YES;
self.backgroundColor = [UIColor clearColor];
self.separatorColor = [UIColor clearColor];
self.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 2);
self.showsVerticalScrollIndicator = NO;
}
return self;
}
To recap: zero, one, or two of the above 2 bugs appears randomly in each table when it is created, but goes away upon scrolling the table even slightly.
Thanks for the patience, as I’m pretty stumped 🙁
FWIW, it happens on the iPhone and iPad, including simulators, running iOS5.
I am assuming your problem was due to datasource and delegate. Try to set your data source and delegate for the class where you creates and uses your tableView.
change the following code from your subclass
to super class like this