开发者

UITableViewController subview: Tell pushViewController to owning UIViewController

I have a UINavigationViewController and inside that I have added a UITableViewController as a subview.

I'd like to be able to tell the UINavigationViewController pushViewController from inside the UITableViewController, but I am unable to retrieve th开发者_Go百科e correct navigationController object.

I have tried some of the methods discussed in this thread, but I cannot get the navigationController for the view.

Is there a way to get a reference for the 'owning' view for a subview?

EDIT: I was able to do this:

[[(MyAppDelegate *)[[UIApplication sharedApplication] delegate] mainViewController].navigationController pushViewController:oOptionsViewController animated:YES];

To make it work. But the issue is just I'd like to do it without necessarily knowing the specific name of the navigationController (say it I have several of these instances, where I use the same class, but they may be used in other navigation controllers..)


I think what you've done there is perfect.

navigationController is an instance-variable, so each controller instance will get its own, and they can be set to different things depending on what navigation element they're added to.

Later,
Blake.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜