【问题标题】:How to implement apple watch crown delegate using objective c如何使用objective c实现苹果手表皇冠代表
【发布时间】:2018-05-21 12:54:11
【问题描述】:

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

【问题讨论】:

    标签: objective-c apple-watch


    【解决方案1】:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多