How do I reference the detailViewController on an iPad that is using a splitViewController

前端 未结 3 464
不思量自难忘°
不思量自难忘° 2021-01-24 20:07

I setup a project on XCode 4.3 and IOS 5 without using storyboards for both iPhone and iPad using the default Master/Detail setup from the create new project dialog.

The

3条回答
  •  被撕碎了的回忆
    2021-01-24 20:55

    If you have a pointer to the split view controller itself, you can do:

    [(GeoDetailViewController *)[[(UINavigationController *)[[splitViewController viewControllers] objectAtIndex:1] viewControllers] objectAtIndex:0] populateDisplay:currentShape];
    

    To get the pointer to your split view, you will probably have to go via your app delegate:

    UISplitViewController *splitViewController = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] splitViewController];
    

    (assuming that you are using the default split view controller template - YMMV depending on how you have implemented it)

    Note that when you create your split view, you must set the detail view controller to be a GeoDetailViewController - if you are not and you cannot for app design reasons, I can edit my answer to work around that.

提交回复
热议问题