ASVisibilityDepth Protocol Reference

Conforms to NSObject
Declared in ASVisibilityProtocols.h

Overview

ASVisibilityDepth

“Visibility Depth” represents the number of user actions required to make an ASDisplayNode or ASViewController visibile. AsyncDisplayKit uses this information to intelligently manage memory and focus resources where they are most visible to the user.

The ASVisibilityDepth protocol describes how custom view controllers can integrate with this system.

Parent view controllers should also implement @c ASManagesChildVisibilityDepth

– visibilityDepth required method

Visibility depth

- (NSInteger)visibilityDepth

Discussion

Represents the number of user actions necessary to reach the view controller. An increased visibility depth indicates a higher number of user interactions for the view controller to be visible again. For example, an onscreen navigation controller’s top view controller should have a visibility depth of 0. The view controller one from the top should have a visibility deptch of 1 as should the root view controller in the stack (because the user can hold the back button to pop to the root view controller).

Visibility depth is used to automatically adjust ranges on range controllers (and thus free up memory) and can be used to reduce memory usage of other items as well.

Declared In

ASVisibilityProtocols.h

– visibilityDepthDidChange required method

Called when visibility depth changes

- (void)visibilityDepthDidChange

Discussion

@c visibilityDepthDidChange is called whenever the visibility depth of the represented view controller has changed.

If implemented by a view controller container, use this method to notify child view controllers that their view depth has changed @see ASNavigationController.m

If implemented on an ASViewController, use this method to reduce or increase the resources that your view controller uses. A higher visibility depth view controller should decrease it’s resource usage, a lower visibility depth controller should pre-warm resources in preperation for a display at 0 depth.

ASViewController implements this method and reduces / increases range mode of supporting nodes (such as ASCollectionNode and ASTableNode).

Declared In

ASVisibilityProtocols.h