Is there any way dynamically create pages in a page-based navigation? In every example I read, the pages were created as Interface Controllers and linked in the Storyboard.
Here is the way to do it
WKInterfaceController.reloadRootControllersWithNames(["pageController", "pageController"], contexts: ["pageController", "pageController"])
To avoid infinite loop use:
static BOOL first = YES;
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
if (first) {
[WKInterfaceController reloadRootControllersWithNames:[NSArray arrayWithObjects:@"SinglePageICIdentifier",@"SinglePageICIdentifier", nil] contexts:[NSArray arrayWithObjects:@"First",@"Second", nil]];
first = NO;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With