-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASViewController] Support optional node #2810
[ASViewController] Support optional node #2810
Conversation
This is really awesome Huy! I've heard that ASViewController's |
@nguyenhuy After looking over this PR it's a really nice improvement idea, but I'm not pretty sure if we should introduce having to test if the What about having something like a |
1667fb4
to
907f9a9
Compare
@maicki Thank you for the feedbacks. I've came up with a simpler fix. In case users don't provide ASViewController with a node (by using I tested this approach with ASDKgram and didn't find any problem. Given the fact that we currently don't even support |
- If a node isn't provided by developers via -initWithNode:, a default one will be created and used internally. - This allows developers to use ASViewController like a normal UIViewController and as a base class for all view controllers among which some use a node hierarchy and some don't.
907f9a9
to
510ce09
Compare
|
||
_node = [[ASDisplayNode alloc] initWithViewBlock:^UIView * _Nonnull{ | ||
return [[UIView alloc] init]; | ||
}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use simply [[ASDisplayNode alloc] init]
here because using a view block results in a wrapper node, which has limited capacity compared to a node using _ASDisplayView
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thanks. Fixing.
2912ed5
to
8969e1a
Compare
- If its node isn't provided by users, don't replace the view controller's view with the default node's view because it might be loaded from a nib. - Init a vanilla ASDisplayNode if a node isn't provided.
8969e1a
to
95cc041
Compare
It looks like this has been updated by @maicki in the linked PR. Closing. |
This PR makes ASViewController's node optional. This allows developers to use ASViewController like a normal UIViewController. More importantly, it can be used as a base class for view controllers among which some use a node hierarchy and some don't.
Resolve #2760.