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];
}
}];
}
}
@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:
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:
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.