strange situation of UITableView when I want to scroll it

Posted by ivanlw on Stack Overflow See other posts from Stack Overflow or by ivanlw
Published on 2012-06-03T04:32:13Z Indexed on 2012/06/03 4:41 UTC
Read the original article Hit count: 128

Filed under:
|
|

I'm building an easy app for chatting, each time I type in a sentence, the sentences is added into an array(which used to load the table view in cellForRowAtIndexPath delegate method), then I reload the table view. At last I use the following code to scroll the table view to the bottom

if ([self.chatList numberOfRowsInSection:0] != 0) {
        NSUInteger rowCount = [self.chatArray count];
        NSIndexPath* indexPath = [NSIndexPath indexPathForRow:rowCount-1 inSection:0];
        [self.chatList scrollToRowAtIndexPath:indexPath 
                         atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

however, the table view sometimes performs well, sometimes only scrolls to the second to the last line……

© Stack Overflow or respective owner

Related posts about iphone

Related posts about scroll