滚动到底部后,在表视图中加载数据

时间:2014-10-17 15:11:58

标签: uitableview uiscrollview

我有一个初始表unreadmessagesArrays,女巫完美显示。 但是想要滚动到底部并加载另一行数据.. 我用过这个:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

CGFloat currentOffset = scrollView.contentOffset.y;
CGFloat maximumOffset = scrollView.contentSize.height - scrollView.frame.size.height;

if (maximumOffset - currentOffset <= 10.0) {
      [self insertRowInTableView];
        }
}


-(void)insertRowInTableView {
[self.unreadmessagesArray addObject:self.messagesIfScroll];

[mytableView beginUpdates];
NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:([self.unreadmessagesArray count] - 1) inSection:0]];
[mytableView insertRowsAtIndexPaths:paths withRowAnimation:NO];
[mytableView endUpdates];
[mytableView reloadData];

}

-(void)getMessagesIfScollToBottom {
self.messagesIfScroll = [NSMutableArray arrayWithArray:responseA];

}

我得到的错误是:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance 0xa20b620'

问题出在哪里? 谢谢

1 个答案:

答案 0 :(得分:0)

在您的代码中使用此代码

[self.unreadmessagesArray addObjectsFromArray:self.messagesIfScroll];

而不是[self.unreadmessagesArray addObject:self.messagesIfScroll];