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?
Asked
Active
Viewed 1,197 times
2 Answers
5
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

Bocaxica
- 3,911
- 3
- 37
- 54
-
For me, it only works if I assign a fixed height to the group. if the whole screen has match content size, it doesn't work. It doesn't say anything about that in the documentation. Am I missing something? – iVentis Mar 07 '19 at 16:05
1
No. The only way to programmatically scroll an interface with WatchKit is by scrolling to a specific row in a WKInterfaceTable
.

Mike Swanson
- 3,337
- 1
- 17
- 15