Reputation: 1489
I'm trying to write an app that will have a custom tableviewcell so i followed the apple developer sample code, but when i run my app, the screen is completely white. When I put breakpoints/NSLogs in the numberOfSectionsInTableView, numberOfRowsInSection, or the cellForRowAtIndexPath, nothing shows.
Here is my delegate.m
RootViewController *rootViewController = [[RootViewController alloc]initWithStyle:UITableViewStylePlain];
rootViewController.displayList=[self displayList];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController=aNavigationController;
[aNavigationController release];
[rootViewController release];
[window addSubview:[navigationController view]];
[self.window makeKeyAndVisible];
And this is the cellForRowAtIndexPath in my RootViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"TableCell";
TableCell *tableCell = (TableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (tableCell == nil) {
tableCell = [[[TableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
tableCell.frame=CGRectMake(0.0, 0.0, 320.0, 60);
}
NSLog(@"71");
return tableCell;
}
I know that the cellForRowAtIndexPath won't show if there are no rows, but shouldn't the numberOfRowsInSection at least work? I even commented the numberOfRowsInSection out and the app was still able to build (still blank though)
Thanks
Upvotes: 1
Views: 1507
Reputation: 4041
it sounds like either: datasource and delegates not hooked up. can be tested by
NSLog(@"%@,%@",tableView.delegate, tableView.datasource);
if they show up as null you have found your issue. if not that, then check for spelling mistakes in the delegate and datasource methods.
Upvotes: 0
Reputation: 160
Did you hook up the viewcontroller as the owner of the xib file? and then connect the datasource and delegate methods to the file owner?
EDIT: If you haven't created a xib file for your tableview, I recommend it over coding it out. After you create it, just connect everything like I mentioned. Also create one for your tableviewcell, and then load it in the cellForRowAtIndexPath
Upvotes: 1