2014-10-17 37 views
0

我有一個初始表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'

問題出在哪裏? 謝謝

回答

0

在代碼中使用這個代碼

[self.unreadmessagesArray addObjectsFromArray:self.messagesIfScroll];

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

+0

同樣的問題! – lyn87 2014-10-17 17:06:55

+0

'unreadmessagesArray'的類型是什麼?這是NSMutableArray還是NSArray? – 2014-10-18 05:43:18

+0

都是unreadmessageaArray,而messagesIfScroll是NSMutalearray! – lyn87 2014-10-19 12:17:39

相關問題