Asyncdisplaykit: [Question] ASTableView introduce new content from bottom

Created on 16 Jun 2016  Â·  7Comments  Â·  Source: facebookarchive/AsyncDisplayKit

I have a timer for insert message, TimeInterval = 0.2, when the timer it work, i can not scrolling my ASTableView, so what we do?please help~ some code with following:

{
    if (newMessage && ![newMessage isEqual:[NSNull null]]) {
        if (self.dataMutableArray.count == MaxQueueCapacity) {
            [self.dataMutableArray dequeue];
            [self.asTableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
        }
        [self.dataMutableArray enqueue:newMessage];
        [self.asTableView beginUpdates];
        [self.asTableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:[self.dataMutableArray count]-1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
        [self.asTableView endUpdatesAnimated:YES completion:^(BOOL completed) {
            if (completed) {
                [self.asTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.dataMutableArray.count -1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            }
        }];
    }
}
Close if no Reply Community Debugging

All 7 comments

@wangqianjun: This hasn't been reported before, so I'm not sure how to start debugging this one without more details.

Would it be possible to include a sample project? If you command + D on a project folder, it will duplicate it and then you can strip out any not essential. If you don't want to post the project here, feel free to privately send a message to [email protected] or message me (hannah) on the Slack channel.

@hannahmbanana Okay,I will send my demo project for u~ Please note that e-mail,Thank u~

@wangqianjun: if you could include the steps required to reproduce the bug that would be great!

@wangqianjun: The issue is that your scrolling conflicts with the scrollToRowAtIndexPath call. Comment out the line below and everything works.

[weakSelf.asTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:weakSelf.dataMutableArray.count -1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];

If you want to scrollToRowAtIndexPath _after_ a user stops dragging the scrollView, there is a way to do that using UIScrollViewDelegate methods related to dragging.

Does that answer your question? Let me know if I can help in any other way!

@hannahmbanana
Thank you for your answer,but this may not be what I want.
I want to make self growth tableview, from bottom to top. When I slide, it can respond to operations(scroll up, or scroll down). So I realized as follows:

  • insert cell to the tableview bottom
  • scrollToRowAtIndexPath to the bottom

Thank u, anyway.

@wangqianjun: I think I understand what you are trying to describe. If you could provide an example or video of the design you are trying to achieve working in a current app, we could suggest an implementation for you.

If you want the tableView to grow from the bottom to the top, such that cells appear to be inserted at the bottom, like in a messaging application, you can do this by:

  • transform the overall tableView to flip it upside
  • also apply a transform to flip each ASCellNode

Something like this: http://stackoverflow.com/questions/5679835/uitableview-anchor-rows-to-bottom

@hannahmbanana
I will use GCD and some buffer fix the problem that locking main thread. Thank u.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephenkopylov picture stephenkopylov  Â·  5Comments

nguyenhuy picture nguyenhuy  Â·  10Comments

GreatLiyi picture GreatLiyi  Â·  3Comments

modLX4 picture modLX4  Â·  8Comments

Luis-X picture Luis-X  Â·  7Comments