Home asdisplaynode-interfaceState
Post
Cancel

asdisplaynode-interfaceState

ASDisplayNode+InterfaceState.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
typedef NS_OPTIONS(NSUInteger, ASInterfaceState)
{
    /** The element is not predicted to be onscreen soon and preloading should not be performed */
    ASInterfaceStateNone          = 0,
    /** The element may be added to a view soon that could become visible.  Measure the layout, including size calculation. */
    ASInterfaceStateMeasureLayout = 1 << 0,
    /** The element is likely enough to come onscreen that disk and/or network data required for display should be fetched. */
    ASInterfaceStatePreload       = 1 << 1,
    /** The element is very likely to become visible, and concurrent rendering should be executed for any -setNeedsDisplay. */
    ASInterfaceStateDisplay       = 1 << 2,
    /** The element is physically onscreen by at least 1 pixel.
     In practice, all other bit fields should also be set when this flag is set. */
    ASInterfaceStateVisible       = 1 << 3,
    
    /**
     * The node is not contained in a cell but it is in a window.
     *
     * Currently we only set `interfaceState` to other values for
     * nodes contained in table views or collection views.
     */
    ASInterfaceStateInHierarchy   = ASInterfaceStateMeasureLayout | ASInterfaceStatePreload | ASInterfaceStateDisplay | ASInterfaceStateVisible,
};

ASInterfaceStateDelegate

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@protocol ASInterfaceStateDelegate <NSObject>

/**
 * @abstract Called whenever any bit in the ASInterfaceState bitfield is changed.
 * @discussion Subclasses may use this to monitor when they become visible, should free cached data, and much more.
 * @see ASInterfaceState
 */
- (void)interfaceStateDidChange:(ASInterfaceState)newState fromState:(ASInterfaceState)oldState;

/**
 * @abstract Called whenever the node becomes visible.
 * @discussion Subclasses may use this to monitor when they become visible.
 * @note This method is guaranteed to be called on main.
 */
- (void)didEnterVisibleState;

/**
 * @abstract Called whenever the node is no longer visible.
 * @discussion Subclasses may use this to monitor when they are no longer visible.
 * @note This method is guaranteed to be called on main.
 */
- (void)didExitVisibleState;

/**
 * @abstract Called whenever the the node has entered the display state.
 * @discussion Subclasses may use this to monitor when a node should be rendering its content.
 * @note This method is guaranteed to be called on main.
 */
- (void)didEnterDisplayState;

/**
 * @abstract Called whenever the the node has exited the display state.
 * @discussion Subclasses may use this to monitor when a node should no longer be rendering its content.
 * @note This method is guaranteed to be called on main.
 */
- (void)didExitDisplayState;

/**
 * @abstract Called whenever the the node has entered the preload state.
 * @discussion Subclasses may use this to monitor data for a node should be preloaded, either from a local or remote source.
 * @note This method is guaranteed to be called on main.
 */
- (void)didEnterPreloadState;

/**
 * @abstract Called whenever the the node has exited the preload state.
 * @discussion Subclasses may use this to monitor whether preloading data for a node should be canceled.
 * @note This method is guaranteed to be called on main.
 */
- (void)didExitPreloadState;

/**
 * @abstract Called when the node has completed applying the layout.
 * @discussion Can be used for operations that are performed after layout has completed.
 * @note This method is guaranteed to be called on main.
 */
- (void)nodeDidLayout;

/**
 * @abstract Called when the node loads.
 * @discussion Can be used for operations that are performed after the node's view is available.
 * @note This method is guaranteed to be called on main.
 */
- (void)nodeDidLoad;

/**
 * @abstract Indicates that the receiver and all subnodes have finished displaying.
 * @discussion May be called more than once, for example if the receiver has a network image node.
 * This is called after the first display pass even if network image nodes have not downloaded anything
 * (text would be done, and other nodes that are ready to do their final display). Each render of
 * every progressive jpeg network node would cause this to be called, so this hook could be called up to
 * 1 + (pJPEGcount * pJPEGrenderCount) times. The render count depends on how many times the downloader calls
 * the progressImage block.
 * @note This method is guaranteed to be called on main.
 */
- (void)hierarchyDisplayDidFinish;

@optional
/**
 * @abstract Called when the node is about to calculate layout. This is only called before
 * Yoga-driven layouts.
 * @discussion Can be used for operations that are performed after the node's view is available.
 * @note This method is guaranteed to be called on main, but implementations should be careful not
 * to attempt to ascend the node tree when handling this, as the root node is locked when this is
 * called.
 */
- (void)nodeWillCalculateLayout:(ASSizeRange)constrainedSize;

@end
This post is licensed under CC BY 4.0 by the author.