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

时间:2015-05-29 17:10:58

标签: ios swift watchkit apple-watch wkinterfacegroup

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

2 个答案:

答案 0 :(得分:5)

您可以在WatchOS 4之后执行此操作。 WKInterfaceController有一个函数。

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

只需指定要滚动到的object(例如,这可能是WKInterfaceGroup),并在屏幕上指定scrollPosition它应该滚动到(在您的情况下{ {1}})你很好。所以在你的WKInterfaceController类中:

.top

Read more on this in the Apple Developer documentation for WKInterfaceController

And the possible values for scrollPosition

答案 1 :(得分:1)

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