I just came across a situation where my implementation of a tableview is working in 3.2 but fails to fire any of the tableview methods in iOS 4. The view controller in question is defined as a UIViewController and is setup to adopt the UITableViewDataSource and UITableViewDelegate protocols, and I'm hooking the tableview up as the view's datasource and delegate via IB.
Definition in .h:
@interface FooViewController : UIViewController <UITableViewDataSource,
UITableViewDelegate> {
IBOutlet UITableView *itemTable;
}
@property (nonatomic, retain) IBOutlet UITableView *itemTable;
.m:
@synthesize itemTable;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"numberOfSectionsInTableView fired!");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSLog(@"numberOfRowsInSection fired!");
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
This appears to work fine in < 4.0, but in 4 it just simply bypasses firing any of these methods. Am I by chance doing it incorrectly and being caught up by something being fixed in 4.0?