简体   繁体   中英

uitableview doesn't scroll to bottom

I have a UITableView where I add rows dynamically. Basically a chat app.

I need to scroll the UITableView to bottom after reloadData

My code is:

It scrolls to here: https://dl-web.dropbox.com/get/Screen%20Shot%202014-12-05%20at%2013.04.23.png?_subject_uid=44249794&w=AADgJkJJOGK_ANH_cXWnxeXmhFmF5KHjZllg-kP66HARdw

When manually scrolling, I can scroll even further to here: https://dl-web.dropbox.com/get/Screen%20Shot%202014-12-05%20at%2013.05.19.png?_subject_uid=44249794&w=AADtQEfMHMy0Ounri5W3gBTLNgR4uckT_gBdYQel9vD1qQ

My code:

 [_chatTable reloadData];
 NSIndexPath* indexPath = [NSIndexPath indexPathForRow: [[AppData getChatLog]count]-1 inSection: 0];
 [_chatTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];

I need the UITableView to scroll all the way to the bottom.

Sorry,I couldn't open up the given links.Try this

UITableView *yourTableView = yourTableViewToBeSetHere;

CGRect lastCellRect = CGRectMake(0, CGFLOAT_MAX, 50, 50);

// Scroll to the particular rect
[yourTableView scrollRectToVisible:lastCellRect
                          animated:YES];

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM