【发布时间】:2015-05-29 17:10:57
【问题描述】:
我在 WKInterfaceGroup 中有一个带有长文本的标签和一个按钮。 我可以在按钮的触摸处理程序上将组滚动到顶部吗?
【问题讨论】:
标签: ios swift watchkit apple-watch wkinterfacegroup
我在 WKInterfaceGroup 中有一个带有长文本的标签和一个按钮。 我可以在按钮的触摸处理程序上将组滚动到顶部吗?
【问题讨论】:
标签: ios swift watchkit apple-watch wkinterfacegroup
您可以从 WatchOS 4 开始执行此操作。 WKInterfaceController 有一个功能。
func scroll(to object: WKInterfaceObject, at scrollPosition: WKInterfaceScrollPosition, animated: Bool)
只需指定您要滚动到的object(例如WKInterfaceGroup),并在它应该滚动到的屏幕上指定scrollPosition(在您的情况下为.top),然后您再好。所以在你的 WKInterfaceController 类中:
scroll(to: objectToShowAtTheTopOfTheScreen, at: .top, animated: true)
Read more on this in the Apple Developer documentation for WKInterfaceController
【讨论】:
没有。使用 WatchKit 以编程方式滚动界面的唯一方法是滚动到 WKInterfaceTable 中的特定行。
【讨论】: