I want to get a hold of the root view of a WKInterfaceController
, without having defined an outlet for it. I want this for a development tool I'm trying to build. Its not code I mean to run in production, so private APIs are welcome here.
Asked
Active
Viewed 1,874 times
0

gardenofwine
- 1,344
- 2
- 15
- 24
-
@8bitcat, `WKInterfaceController` doesn't have a member called `navigationController`. Did you mean the method `popToRootController` in `WKInterfaceController`? If so, I don't see how this answers my question. The method affects the view presented, but I don't get a reference to that view, which is what I'm after. In addition, it has the side effect of changing the UI, which is not what I want. – gardenofwine Aug 12 '15 at 05:44
2 Answers
4
I hope that below code will help you.
WKExtension *sharedExtention = [WKExtension sharedExtension];
WKInterfaceController *rootInterfaceController = sharedExtention.rootInterfaceController;

korat prashant
- 1,523
- 10
- 24
0
Swift 3.0.1 version...
if let yourInterfaceController = WKExtension.shared().rootInterfaceController as? YourInterfaceController {
nowInterfaceController.yourMethod()
}

Justin Domnitz
- 3,217
- 27
- 34