IOS- UITableView 滚动回到顶部

标签 ios objective-c iphone uitableview cell

我在我的项目中使用自定义 UITableView 来显示数据它工作正常但是当我尝试将它滚动到底部时它不会在所需的单元格处停止它总是跳到表格的顶部.只显示 2-3 个单元格。 请建议添加什么来克服这个问题。

我尝试了很多在类似问题中回答的代码,但它们不起作用

我为 UITableView 使用以下代码

newsFeedTable = [[UITableView alloc]init];
    CGFloat Ytablepadding = CGRectGetMaxY(homeView.frame)+60;
    CGFloat heighttable = 700;
    newsFeedTable.frame = CGRectMake(0,Ytablepadding, self.view.frame.size.width, heighttable);
    [self.view addSubview:newsFeedTable];
    newsFeedTable.delegate=self;
    newsFeedTable.dataSource= self;

最佳答案

在你的 viewDidload 中添加这段代码:

NSIndexPath *myIndexPath = [NSIndexPath indexPathForRow:AddYourLastIndex inSection:0];
[self.tbl_presentation selectRowAtIndexPath:myIndexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];

关于IOS- UITableView 滚动回到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32710836/

相关文章:

ios - 如何使用 iOS 以编程方式生成 PDF 的缩略图?

ios - 无法在 UIAlertView 中使用键盘输入

objective-c - 更新 NSOpenGLView 大小

javascript - 如何确定捏合缩放 Action 的速度?

ios - 什么时候应该使用数据源(协议(protocol))与在属性或初始化上设置类数据?

ios - 点击时更改 TableView 单元格的 UIImage

ios - Collection View Controller 未添加为 subview

iphone - 设置 TableView setEditing 时无法选择 UITableViewCell

iphone - 将标签文本与图像组合

javascript - 在 mobile safari 中查看 web 应用程序时,是否有一些默认弹出窗口可供在 itunes 上下载应用程序商店?