which should be another TKController instance, or one of its subclasses. TuneKit will then automatically set up user
interaction that navigates between controllers when the user activates the element given in the selector.
Also, you can define an element that acts as a back button, thus popping the controller from the navigation stack. Simply
use the backButton property and set it to whatever CSS selector matches the element you wish to use as a trigger to go
back.
Custom Transitions
As the user navigates from controller to controller, the TKNavigationController will use a fade transition by default, but you
can provide a custom transition. Use the becomesActiveTransition and becomesInactiveTransition properties. Both these
properties expect an object supporting the following:
■
properties: an array of CSS properties that are transitioned during the transition. REQUIRED.
■
base: an associative array of basic properties to apply before the transition starts. Even indexes are CSS properties and
odd indexes are values. OPTIONAL.
■
from: an array of CSS values for the initial state of the transition, each index mapping the property at the same index in
properties. OPTIONAL.
■
to: an array of CSS values for the end state of the transition, each index mapping the property at the same index in
properties. REQUIRED.
■
duration: a float duration for the transition in seconds. OPTIONAL, defaults to 0.5.
■
delay: a float duration for the delay to apply before the transition starts in seconds. OPTIONAL, defaults to 0.
Callbacks
Controllers have a variety of functions that you can override and subclass to monitor their life cycle and various
interactions:
■
viewDidLoad: the controller's view was loaded for the first time, although it may not have been appended to the DOM
tree just yet.
■
viewWillAppear: the controller's view will appear on screen, for instance as it's pushed as the topController of the
navigation stack.
■
viewWillDisappear: the controller's view will disappear from screen, for instance when the user navigates away from it.
■
viewDidAppear: the controller's view has appeared on screen, for instance as it's pushed as the topController of the
navigation stack and the transition has completed.
■
viewDidDisappear: the controller's view has disappeared from screen, for instance when the user navigates away from it
and the transition has completed.
TKNavigationController
Traditionally, you will use a single TKNavigationController instance to manage the navigation between the various
controllers. On top of the TKController properties defined above, TKNavigationController offers two extra properties. The
rootController property lets you define the controller to use as the first controller displayed on screen, while the delegate
property lets you define an optional supporting object that will get delegate method calls to track as controllers are
pushed onto the stack. There are two optional delegate methods for a TKNavigationController:
■
navigationControllerWillShowController(navigationController, controller): notifies that a controller will appear, either
because it's being pushed, or it was the back controller when the top controller got popped off the stack. It can be
interesting to implement this delegate method to customize the transitions used on the controller going off-screen and
the one coming on-screen.
iTunes Extras/iTunes LP Development page 4
TuneKit Programming Guide v1.0
© 2009 Apple Inc. ! All rights reserved