Apple Watch 的 WatchKit 中是否有 ActivityIndi​​cator? [英] Is there an ActivityIndicator in WatchKit for Apple Watch?

查看:43
本文介绍了Apple Watch 的 WatchKit 中是否有 ActivityIndi​​cator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple Watch 的 WatchKit 中是否有 ActivityIndi​​cator(或类似的东西)?你们如何向用户反馈一些更持久的后台活动?

Is there an ActivityIndicator (or something like it) in WatchKit for Apple Watch? How do you all give the user feedback about some longer lasting background activity?

推荐答案

编辑: 这个答案最初是在 Apple Watch 型号推出之前发布的蜂窝和 wifi 连接,因此可能不再适用于较新型号的设备(考虑到显着的性能改进).

Apple 开发者论坛上的这个主题有来自Apple 工程师解释为什么您不应该使用 Apple Watch 执行网络操作.

This thread on the Apple Developer forums has an authoritative answer from an Apple engineer about why you shouldn't be performing network operations with Apple Watch.

不通过手表应用/扩展程序执行网络操作有两大原因:

There are two big reasons not to perform networking operations from your watch app / extension:

  1. 用户与手表的互动时间很短.请参阅人机界面指南这个.

如果您以几分钟为单位衡量与 iOS 应用的交互,则可以期望以秒为单位衡量与 WatchKit 应用的互动.所以交互应该简短,界面应该简单.

If you measure interactions with your iOS app in minutes, you can expect interactions with your WatchKit app to be measured in seconds. So interactions should be brief and interfaces should be simple.

  • 如果网络请求没有完成,系统可能会死锁.

  • The system may deadlock if the network request does not complete.

    我们的建议是,一般而言,您不应在 WatchKit 扩展程序中执行复杂的网络操作...

    Our recommendation is that, in general, you should not perform complex networking operations inside a WatchKit Extension...

    [Apple 建议开发人员] 有一个进程负责更新您的数据库(可能是您的 iOS 应用程序)中的信息,然后您的扩展程序将(基本上)拥有对该 [缓存] 数据库的只读访问权限....

    [Apple recommends that developers] have a single process that is in charge of updating the information in your database (likely your iOS app), and then your extensions would have (essentially) read-only access to this [cached] database....

  • <小时>

    话虽如此.如果你真的需要一个 UIActivityIndi​​cator,rdar://19363748(我认为这个还没有开放雷达),开发者已经提交了官方支持请求.


    That being said. If you really need a UIActivityIndicator, rdar://19363748 (I don't think this one has been open radar-ed yet), developers have already filed requests for official support.

    您可以按照您选择的活动指示器样式创建一系列图像,然后使用 startAnimatingWithImagesInRange:duration:repeatCount: API 为它们设置动画.有关 动画的示例,请参阅 Apple 的 Lister 应用程序.

    You can create a series of images in the activity indicator style of your choice and then animate them using the startAnimatingWithImagesInRange:duration:repeatCount: API. See Apple's Lister app for an example of wkinterfaceimage animation.

    或者,查看这里 用于 WatchKit 动画教程和包括微调"图形.

    Alternatively, look here for a WatchKit Animation tutorial and included "spinner" graphics.

    这篇关于Apple Watch 的 WatchKit 中是否有 ActivityIndi​​cator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆