AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

[Question] How to add ASScrollNode into ASCellNode?

Open nttravn opened this issue 11 years ago • 7 comments

Hi All, I want to display 2-3 image in a cell on table. I did create a ASScrollNode and add it into ASCellNode but I don't use it. My code:

@interface MyCell:ASCellNode
{
      ASScrollNode *_scrollNode;
}
@end
@implementation
- (id)init {
    self = [super init];
    if(self) {
       _scrollNode =[ [ASScrollNode alloc] init];
      [self addSubnode:_scrollNode];
   }
   return self;
}
@end

nttravn avatar Mar 11 '15 16:03 nttravn

ASScrollNode is a lightweight wrapper around UIScrollView, so you can interact with them both the same way — instead of adding image views as UIScrollView subviews, you can add image nodes as ASScrollNode subnodes. The Ray Wenderlich UIScrollView tutorial might be helpful, though note that you'll have to implement your scroll node in code, not Interface Builder.

secretiverhyme avatar Mar 11 '15 20:03 secretiverhyme

Thanks secretiverhyme :). I did add a ASScrollNode in to ASCellNode and I add two ASImageNode into ASScrollNode but I can't set content size for this ASScrollNode. Could you help me about this?

nttravn avatar Mar 12 '15 01:03 nttravn

The view property on ASScrollNode is a UIScrollView, so you should be able to do

_scrollNode.view.contentSize = CGSizeMake(width, height);

with the caveat that accessing this property will force the view to be loaded. contentSize and friends aren't available on ASScrollNode itself (pull requests welcome! check out the UIViewBridge category for reference) so in order to avoid loading the UIScrollView too soon and locking the scroll node to the main thread, you should set contentSize in your cell node's -layout implementation.

secretiverhyme avatar Mar 12 '15 03:03 secretiverhyme

Many thanks to secretiverhyme. You help me so much :). One more issue: UI look like "blur" when I use ASTextNode, ASImageNode... so how clear it?

nttravn avatar Mar 12 '15 10:03 nttravn

@nttravn do you experience the blur issue with the ASDK current version ?

macistador avatar Feb 08 '16 11:02 macistador

@nttravn - I'm very sorry for the delay in response to your blur issue. Are you still having this problem? If so, I'd be very happy to help you out if you can describe more details of the problem.

I hope you've been able to use the framework!

appleguy avatar Mar 31 '16 05:03 appleguy

@nttravn: thanks for contributing to the AsyncDisplayKit community by asking your question here! Due to the length of time it’s been since this thread was active, I’m going to mark this issue as closed. If you are still having troubles, feel free to reopen it. I hope you have been able to use the framework!

appleguy avatar May 11 '16 08:05 appleguy