2

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.

Interface controller with table - - -> enter image description here

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). enter image description here 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?

Roboris
  • 344
  • 3
  • 16
  • Please check out this tutorial by AppCoda: http://www.appcoda.com/selectable-table-watchkit/ – Mr. Xcoder Jan 09 '17 at 20:22
  • @Xcoder123 The above tutorial shows how to navigate from a table row to a single controller, NOT a set of page-based controllers (which is my query). – Roboris Jan 10 '17 at 05:52
  • sorry, my mistake – Mr. Xcoder Jan 10 '17 at 07:17
  • Quite often Apple apps use private APIs to do some things that otherwise couldn't be done. This might be one example. – EmilioPelaez Feb 13 '19 at 04:06
  • I'm trying to implement this using swiftUI would it be possible for you to [help](https://stackoverflow.com/questions/58509975/using-multiple-hosting-controllers-in-swiftui-on-watchos) ? – 39fredy Oct 23 '19 at 17:28

1 Answers1

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)
B.Hughes
  • 26
  • 1
  • I'm trying to implement this using swiftUI would it be possible for you to [help](https://stackoverflow.com/questions/58509975/using-multiple-hosting-controllers-in-swiftui-on-watchos) ? – 39fredy Oct 23 '19 at 17:28