首页 > 解决方案 > 如何使用objective c实现苹果手表皇冠代表

问题描述

我正在开发需要使用 Crown 更新标签值的 Apple Watch 应用程序。我已经使用 swift 实现了该功能。在swift中,我们有一个名为crownSequencer的属性来实现皇冠委托,
crownSequencer.delegate=self; crownSequencer.focus(); 但我无法在目标c中实现它,因为目标c没有显示任何名为crownSequencer 任何帮助的属性,我们将不胜感激。

标签: objective-capple-watch

解决方案


CrownSequence 可以通过 InterfaceController 对象访问。

在 Objective C 中,它可以通过以下方式访问:

- (void)awakeWithContext:(id)context {
    [super awakeWithContext:context];
    // Configure interface objects here.
    self.crownSequencer.delegate = self;
}
- (void)willActivate {
   [super willActivate];
   [self.crownSequencer focus];
}

注意 ::[self.crownSequencer focus] 不应在 (void)awakeWithContext:(id)context 内调用,否则将不会调用委托方法

在这里您可以找到更多信息

https://developer.apple.com/documentation/watchkit/wkcrownsequencer?language=objc


推荐阅读