ios - 如何使用动画以编程方式隐藏和显示 WKInterfaceGroup?

标签 ios xcode animation caanimation watchkit

此问题中的解决方案* 使用 setHidden 来隐藏和取消隐藏 WKInterfaceGroup:

    atypeofGroup.setHidden(true)
    atypeofGroup.setHidden(false)

但问题是,群会突然出现又消失,看起来不专业。有人可以指导我吗?不确定是否与此有关:
    atypeofGroup.animationDidStart(anim: CAAnimation!)

* hide and show WKInterfaceGroup programmatically

最佳答案

这是一个很好的问题,但是用当前的 WatchKit 的实现来动画两组之间的变化是不可能的。 .我当然希望它也是。

您唯一的选择是完全通过reloadRootControllersWithNames:contexts: 切换接口(interface) Controller 。或使用您首先列出的方法显示/隐藏几个组。这是一个小例子,说明如何从 SimpleInterfaceController 切换。到 FirstInterfaceControllerSecondInterfaceController在一个页面集中。

class SimpleInterfaceController : WKInterfaceController {
    override func willActivate() {
        super.willActivate()

        let names = ["FirstInterfaceIdentifier", "SecondInterfaceIdentifier"]
        WKInterfaceController.reloadRootControllersWithNames(names, contexts: nil)
    }
}

我不确定您在哪里找到以下代码片段,但它肯定不是 WKInterfaceGroup 上公共(public) API 的一部分.
atypeofGroup.animationDidStart(anim: CAAnimation!)

虽然我知道这些答案都不是理想的,但它们是我们目前所能获得的全部。如果您有时间,我建议您在 Apple 的 bug reporting system 上提交功能请求。 .

关于ios - 如何使用动画以编程方式隐藏和显示 WKInterfaceGroup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28826336/

相关文章:

javascript - SVG - 动画问题

ios - UIBarButton 未显示在 UINavigationBar 中

ios - Xcode/Simulator 与物理设备上的 React Native 字体大小不同

iOS5 无法读取 Riven.bundle 的符号(找不到文件)

iphone - UITableViewCell 动画

javascript - 在页面之间共享 Webkit 转换数据

iphone - 释放对象,我理解正确吗?

ios - 在屏幕的一部分上呈现 View ;禁用周围 View 但保持它们可见

ios - 如何在 xcode 和 swift 中使用不受支持的类(新功能)构建项目

ios - 错误: Missing argument for parameter #1 in call when I am calling a function from different class in Swift