Reputation:
I have a label with a long text and a button inside a WKInterfaceGroup. Can I scroll the group to top on the button's touch handler?
Upvotes: 1
Views: 1210
Reputation: 4680
You can do this since WatchOS 4. The WKInterfaceController has a function for this.
func scroll(to object: WKInterfaceObject, at scrollPosition: WKInterfaceScrollPosition, animated: Bool)
Simply specify the object
(this could for example be a WKInterfaceGroup
) you want to scroll to, and specify the scrollPosition
on the screen it should scroll to (in your case .top
) and you're good. So in your 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
Upvotes: 4
Reputation: 3347
No. The only way to programmatically scroll an interface with WatchKit is by scrolling to a specific row in a WKInterfaceTable
.
Upvotes: 1