开发者

Create a UINavigationController to use inside a UITableViewController without Interface Builder

Maybe this is a too simple question but I'm kind of stuck here. I've implemented a class that inherits from UITableViewController. This class is the root controller of a split view I'm building by code, not with Interface Builder. The problem is that I'm trying to show a detail view from the accesory view in the table, and the navigationController attribute in my instance is nil. I don't have any idea of how to in开发者_JAVA百科stantiate a new UINavigationController to be able to display a detailed view in my code.

This is how I'm trying to use the accesory button:

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

    PartDetailViewController *partDetailViewController =
                          [[PartDetailViewController alloc] initWithNibName:@"PartDetailView" bundle:[NSBundle mainBundle]];

    [self.navigationController pushViewController:partDetailViewController animated:YES];
    [partDetailViewController release];
}

Any hint would be really appreciated.

Thanks in advance,

Federico


If self.navigationController is nil means that you have not "pushed" your UITableViewController instance inside a navigation controller.

So I can imagine, from your description, that you have an iPad app with a UISplitViewController and your table has been instantiated inside the "root" view controller of the split view, so having a hierarchy like:

UISplitViewController ==>(root)==> UITableViewController

. If this is the case, what you have to do is to create a UINavigationController, push the table view controller inside the UINavigationController and then define the split view "root" controller to be the UINavigationController, according to this schema:

UISplitViewController ==>(root)==> UINavigationViewController ==> UITableViewController

Hope this can help you.


Create a UINavigationController, add the UITableViewCOntroller to the UINavigationController and add the UINavigationController to the split view's view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜