How does the inbuilt Workout app on Apple Watch navigate from main table row to a set of page-based controllers?

早过忘川 提交于 2020-02-02 11:12:30

问题


I was trying to mimic the Workout app for practise. And I got stuck at figuring out how to do this navigation from these table rows in the main screen to the 3/4 Workout starting screens which are page-based and seem to be hierarchical, with a back button on top left. They are most certainly not Modal as they do not appear from the bottom.

- - ->

However I did not find any way to connect a row to a set of page-based interface controllers with push segue.

This is what I tried:

1- presentController(withNames:, contexts:) which presents the page-based layout MODALLY.

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
        let controllers = controllersForExercise(categories[rowIndex])
        presentController(withNames: controllers, contexts: nil)
    }

func controllersForExercise(_ exercise: Exercise) -> [String] {
        // Returns a bunch of Identifiers (from Storyboard) as [String]
    }

2- In the storyboard, I connected the table row to the first of these page-based interface controllers by a push segue, and then connected that controller to the other three page-based interface controllers sequentially using nextPage segue (relationship). This did not work. It just segues with the back button on top left but showed only the first interface controller, not the other three as page-based controllers. I am assuming it is happening because table row selection makes it a hierarchical navigation while this is a page-based navigation, and the two cannot be mixed according to Apple.

So I am baffled about how Apple manages it themselves. Any clues?


回答1:


OBJC:

+ (void)reloadRootPageControllersWithNames:(NSArray<NSString *> *)names 
                              contexts:(NSArray *)contexts 
                           orientation:(WKPageOrientation)orientation 
                             pageIndex:(NSInteger)pageIndex;

SWIFT:

class func reloadRootPageControllers(withNames names: [String], 
                        contexts: [Any]?, 
                     orientation: WKPageOrientation, 
                       pageIndex: Int)


来源:https://stackoverflow.com/questions/41556197/how-does-the-inbuilt-workout-app-on-apple-watch-navigate-from-main-table-row-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!