Reputation: 115
I'm not doing anything tricky. Using the standard TableView Controller from the default template provided by Apple, I just changed the Style to "Subtitle". The change is reflected in the storyboard however it remains basic in the simulator.
The only modifications to the project are: - I imbedded the navigation controller in a tab controller - I inserted a search bar and search display controller in the tableview - I added an object to import XML data from a web site
This project is a bare bones (stripped down) version of a different project that is active in production now but uses only NSDictionary instead of core data. This new project is my attempt to learn care data however I can't get past this pesky problem.
I changed my cell identifier from "Cell" to "aeJobCell" without updating the code and the app ran successfully anyway. It didn't complain that there was no cell identifier of "Cell". Then I put a test in my code to make sure it was using the correct identifier and it was. The labels are getting set properly. The data shows up in the cell however I don't get the subtitle.
I do not have enough reputation to post images, sorry. I'll paste code and describe what I have as best as I can.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
ImportedAEJob *aeJob = nil;
if (tableView == self.searchDisplayController.searchResultsTableView) {
cell = [tableView dequeueReusableCellWithIdentifier:@"aeJobCell"];
aeJob = [self.searchResults objectAtIndex:indexPath.row];
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"aeJobCell" forIndexPath:indexPath];
aeJob = [self.fetchedResultsController objectAtIndexPath:indexPath];
}
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"aeJobCell"];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
//[self configureCell:cell atIndexPath:indexPath];
[self configureCell:cell forAEJob:aeJob];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
// NSString *aJobNo = [[object valueForKey:@"aeJobNo"] description];
// NSString *aDeliverTo = [[object valueForKey:@"aeDeliverTo"] description];
cell.textLabel.text = [[object valueForKey:@"aeJobNo"] description];
cell.detailTextLabel.text = [[object valueForKey:@"aeDeliverTo"] description];
}
- (void)configureCell:(UITableViewCell *)cell forAEJob:(ImportedAEJob *)aeJob
{
// NSString *aJobNo = aeJob.aeJobNo;
// NSString *aDeliverTo = aeJob.aeDeliverTo;
cell.textLabel.text = aeJob.aeJobNo;
cell.detailTextLabel.text = aeJob.aeDeliverTo;
}
I've reset content and settings, deleted the derived data, restarted my computer, tapped my belly and rubbed my head (and visa versa). I've read more than a dozen posts on this forum but not one of them discusses this specific problem. Most posts regarding cells not displaying properly involve a custom cell, but I am not using a custom cell. I don't even know how to actually.
I've reached the limits of my capacity on this problem. Please help.
<----- EDIT ------->
Heres the changes I made the the app delegate, in case this helps:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
UINavigationController *masterNavigationController = splitViewController.viewControllers[0];
rushMasterViewController *controller = (rushMasterViewController *)masterNavigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
} else {
UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex: 0];
//UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
rushMasterViewController *controller = (rushMasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
}
return YES;
}
Upvotes: 0
Views: 203
Reputation: 104082
The reason the subtitle didn't show up is because you registered the class with this line:
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"aeJobCell"];
When you use a cell that comes from the storyboard, whether a UITableViewCell or your own custom class, you shouldn't register anything. If the cell is defined only in code, then you register the class, and if it's made in a xib file, then you register the nib.
Upvotes: 2