我可以以编程方式滚动 WKInterfaceGroup 吗?

Can I scroll WKInterfaceGroup programmatically?

我在 WKInterfaceGroup 中有一个带有长文本的标签和一个按钮。 我可以在按钮的触摸处理程序上将组滚动到顶部吗?

没有。使用 WatchKit 以编程方式滚动界面的唯一方法是滚动到 WKInterfaceTable.

中的特定行

您可以从 WatchOS 4 开始执行此操作。 WKInterfaceController 有一个功能。

func scroll(to object: WKInterfaceObject, at scrollPosition: WKInterfaceScrollPosition, animated: Bool)

只需指定要滚动到的 object(例如可以是 WKInterfaceGroup),然后指定要滚动到的屏幕上的 scrollPosition(在您的case .top) 你很好。所以在你的 WKInterfaceController class:

scroll(to: objectToShowAtTheTopOfTheScreen, at: .top, animated: true)

Read more on this in the Apple Developer documentation for WKInterfaceController

And the possible values for scrollPosition