Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is method "willActivate" in "WKInterfaceController" already called for the next page?

Tags:

ios

watchkit

I just realized that the method willActivate of WKInterfaceControlleris already called for the next page (not only for the current page).

Is this a new "feature" or a bug? I could not find anything about it in Apple's WatchKit documentation.

How can I avoid initializing page 2 automatically when only page 1 is shown? (I tried to find a way to determine the currently shown page number or title but have not found a solution, yet. See this question.)

(I have updated my Apple Watch to version 1.01 and I use Xcode version 6.3.2.)

like image 902
vomako Avatar asked Oct 19 '22 11:10

vomako


1 Answers

Watch OS 1.0.1 introduced a change that calls willActivate and didDeactivate in succession for the "next" controller in a page-based layout. Presumably, this is to give the next page a chance to update its interface before it's displayed.

Unfortunately, as you've noted, this makes it very difficult (if not impossible) to determine which interface controller has been viewed onscreen. These changes also conflict with the documented behavior of willActivate and didDeactivate, making it even more confusing.

You can read more about this change in Watch OS 1.0.1 Controller Life Cycle Changes.

like image 112
Mike Swanson Avatar answered Oct 22 '22 00:10

Mike Swanson