Domanda

I have a navigation controller with a tableview inside on iphone version. Basically when I tap some row in this table A, sub-tableview controller A1 or A2 is pushed. Now on iPad, I need to show A1 or A2 in detailview in a splitview controller. How should I transform them? It's not in a root view controller.

I tried put my 'table A' view controller in master VC and a blank navigation controller in detail VC in the splitview, but how can I tell detail VC to show what after I select some row in table A?

Thanks...I tried but can't find any solution. I thought it would be pretty easy.

È stato utile?

Soluzione

Have you looked at the template master-detail project that Xcode creates? It demonstrates the approach pretty clearly. Specifically have a look at the didSelectRowAtIndexPath: method of the masterViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
        self.detailViewController.detailItem = object;
    }
}

Essentially your master view controller has a property that holds a reference to your detail view controller. This allows you to send a message to the detail view controller when it needs to display an object

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top