سؤال

I swear I've looked at a half-dozen tutorials and I can't figure out what I'm doing incorrectly. I have a tableview nested within a UIView via IB, and the table both is formatted and populates correctly. I just can't get it to show me the details screen. The table recognizes the tap, and the row is selected, but... the row stays selected. Then, absolutely nothing happens. I can selected other rows with the same results, but nothing ever happens past that. I can move in and out of the view, and have full functionality throughout the entire app. I can even scroll the tableview, but I can never get into the cell detail screen. I've linked all the necessary pieces together in IB.

This is my code for the detail view:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //Get the selected cell detail
    NSString *theString = [secondview objectAtIndex:indexPath.row];

    celldetails *dvController = [[celldetails alloc] initWithNibName:@"celldetails" bundle:nil];
    dvController.cellString = theString;

    [self.navigationController pushViewController:dvController animated:YES];
}

I've tried both "bundle:nil" and "bundle:[NSBundle mainBundle]", but neither produces the desired result. Anyone have a word of advice?

هل كانت مفيدة؟

المحلول

If pushViewController:animated: doesn't do anything, your navigationController could be nil, but otherwise it should definitely work since a UIViewController instance sent to pushViewController:animated: will show some sort of visual change (unless the views are identical and you don't use animation). Try adding an NSLog(@"blah"); line to your didSelectRowAtIndexPath: implementation, just to be sure it's getting called. Or stick a breakpoint in that method.

A bundle of nil is fine. If the .xib was not found, then you'd get debug messages to that effect, so it's finding a .xib. The .xib even has a valid view outlet set since the app crashes if you load a .xib but no view outlet is set.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top