开发者

How to scroll a UITableview opened through a UIPopoverController

开发者 https://www.devze.com 2023-04-05 05:24 出处:网络
In iOS 4, I have a UIPopoverController that opens a UITableViewContr开发者_如何学编程oller with a long list of items (66).

In iOS 4, I have a UIPopoverController that opens a UITableViewContr开发者_如何学编程oller with a long list of items (66). How do I programmatically scroll to a specific cell of the tableview?


    [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndex:1] atScrollPosition: UITableViewScrollPositionNone animated:NO];


You can use this method of UITableView:

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

Parameters

  1. indexPath: An index path that identifies a row in the table view by its row index and its section index.

  2. scrollPosition: A constant that identifies a relative position in the receiving table view (top, middle, bottom) for row when scrolling concludes. See “Table View Scroll Position” a descriptions of valid constants.

  3. animated: YES if you want to animate the change in position, NO if it should be immediate.


NSIndexPath * someRowAtIndexPath = [NSIndexPath indexPathForRow:3 inSection:4];
[tableView scrollToRowAtIndexPath:someRowAtIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号