Reputation: 5104
I'm currently displaying a long label of text plus a button below it to go to the 'next' message.
When the next button is pressed the label adjusts it's height automagically thanks to watch kit's strange auto sizing mechanisms; however the screen does not change positions. I want to scroll the InterfaceController back to the top whenever the label updates. Is this possible with the current Watch Kit SDK?
Upvotes: 2
Views: 1254
Reputation: 3
Swift 5.0 ... this works for me:
where this call is
inside the WKInterfaceController class of the WatchKit Extension app,
my 'btnPrevTee' is a button located at the top of the watch face
scroll(to:btnPrevTee, at:.top, animated:true)
ref: https://developer.apple.com/documentation/watchkit/wkinterfacecontroller/2874208-scroll
Upvotes: 0
Reputation: 2701
This is now possible in watchOS 4. Just use the scrollToObject:atScrollPosition:animated:
method.
Upvotes: 2
Reputation: 13514
Currently, there is no API for the interface controller to scroll to top. But I did a workaround for the same.
func scrollInterfaceToTop() {
tableView.setHidden(false)
tableView.scrollToRow(at: 0)
tableView.setHidden(true)
}
Upvotes: 0
Reputation: 5121
An Apple employee said
Scrolling to the top is only supported on WKInterfaceTable. If you'd like this functionality on a WKInterfaceController, please file a request for it at https://bugreport.apple.com. Thanks! :)
on the developer forums https://devforums.apple.com/message/1074525#1074525
Upvotes: 1