Это может быть достигнуто таким образом,
Представить InterfaceController в pageNavigation с соответствующими значениями контекста,
[self presentControllerWithNames:@[@"TestInterfaceController",@"TestInterfaceController",@"TestInterfaceController"] contexts:@[@"Page 1",@"Page 2",@"Page 3"]];
Затем создайте свойство NSString для отслеживания страницы и метки для ее отображения,
@property (nonatomic, strong) NSString *currentContext;
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *pageLabel;
В awakeWithContext назначьте его свойству NSString,
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
NSLog(@"%@",context);
self.currentContext = context;
}
Отобразите его на willActive,
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
NSLog(@"%@ willActivate",self.currentContext);
[self.pageLabel setText:self.currentContext];
}
Вы также можете определить, когда страница деактивировалась,
- (void)didDeactivate {
// This method is called when watch view controller is no longer visible
[super didDeactivate];
NSLog(@"%@ didDeactivate",self.currentContext);
}
Редактировать: если навигация по страницам настроена с использованием перехода на раскадровку, переопределите этот метод в исходном IntefaceController, из которого вы создали переход модели в контроллер назначения, чтобы предоставить контексты,
- (NSArray *)contextsForSegueWithIdentifier:(NSString *)segueIdentifier {
NSArray *contexts = nil;
if ([segueIdentifier isEqualToString:@"MyPageNavigation"]) {
contexts = @[@"Page 1",@"Page 2",@"Page 3"];
}
return contexts;
}
person
Dhaval Panchal
schedule
22.05.2015