Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic page-based Apple Watch app

I tried to create a page-based Apple Watch app.

As far as I can see, you can create a fixed number of pages for your app in the storyboard.

So I just wonder if there is any way to dynamically programmatically create the pages for your app based on the loaded data?

I.e: a newspaper app in which users can swipe left and right to switch to different articles.

Thanks

like image 478
L N Avatar asked Jan 16 '15 06:01

L N


People also ask

What is the dynamic setting on Apple Watch?

The Dynamic watch face displays photos from your recent Memories, and it updates when you have new ones.

How do I get watch os9?

watchOS 9 is available as a free software update starting today for Apple Watch Series 4 or later paired with iPhone 8 or later and iPhone SE (2nd generation) or later, running iOS 16. For more information, visit apple.com/watchos/watchos-9/.

Does Apple Watch have an API?

Now with watchOS 9, developers have access to a new API to implement a share sheet in their Apple Watch apps. The feature will work pretty much the same way in third-party apps, showing the user options to share content through apps like Messages and Mail.


1 Answers

You can present page based navigation from code. You can specify as many pages as you want, but those pages has to be designed in the Storyboard

func presentControllerWithNames(names: [AnyObject], contexts: [AnyObject]?) // modal presentation of paged controllers. contexts matched to 

Example

Present Page Interfaces for objects. This code show page for every object

let objects  = ["1", "2", "3", "4", "5"]
let controllers = Array(count: objects.count, repeatedValue: "Page")
presentControllerWithNames(controllers, contexts: objects)

Present different Interface for different object object.

let objects  = [1, 2, 3, 4, 5]
let controllers = objects.map { object  in object % 2 == 0 ? "Even-Page" : "Odd-Page" }
presentControllerWithNames(controllers, contexts: objects)
like image 63
Kostiantyn Koval Avatar answered Oct 28 '22 10:10

Kostiantyn Koval