[英]UITableView doesn't remember its scroll position
I can post code, though I'm not quite sure where to start. 尽管我不确定从哪里开始,但是我可以发布代码。 I have a UITableView with custom cells, in the middle tier of a three-level UINavigationView scheme.
我在三级UINavigationView方案的中间层中有一个带有自定义单元格的UITableView。 When I drill down to the bottom level and see details about my data, then use the top-left back button, my table view comes back scrolled all the way to the top, rather than scrolled down to where it was when I last saw it.
当我向下浏览至最底层并查看有关数据的详细信息,然后使用左上角的后退按钮时,我的表格视图将一直返回到顶部,而不是向下滚动到我上次看到的位置。 Where should I look about this?
我应该在哪里看呢?
EDIT: 编辑:
Here's the code in the EventsTableViewController to load an instance of EventsDetailViewController and push it on the navigation controller: 这是EventsTableViewController中的代码,用于加载EventsDetailViewController的实例并将其推送到导航控制器上:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *events = [DataManager sharedDataManager].eventList;
Event *selectedEvent = [events objectAtIndex:[indexPath row]];
EventsDetailViewController *detailController = [[EventsDetailViewController alloc] initWithNibName:@"EventsDetailView" bundle:nil];
[detailController loadEvent:selectedEvent];
MyAppDelegate *del = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:detailController animated:YES];
[detailController release];
}
There's nothing in my EventsTableViewController about reloading the table, as far as I can see--I haven't implemented viewWillAppear or viewDidLoad or any of those. 据我所知,我的EventsTableViewController中没有关于重新加载表的任何内容-我尚未实现viewWillAppear或viewDidLoad或任何一种。
Are you by any chance reloading the table where you shouldn't be? 您是否有机会重新加载不该使用的表? In the ViewWillAppear method for example?
以ViewWillAppear方法为例吗?
I was accidentally instantiating a new copy of my table view whenever I hit this level of the navigation. 每当我到达此级别的导航时,我不小心实例化了表格视图的新副本。 That's all fixed now and this isn't a problem anymore.
现在已全部解决,这不再是问题。
I have a very similar question. 我有一个非常类似的问题。 When I go to the chatView, which is a UIViewController belonging to the navigationController and has a tableView as a subview, and then I scroll to some point, and then I go back, and then I go back to the chatView, it starts at the top again.
当我转到chatView时,它是属于navigationController的UIViewController,并且具有tableView作为子视图,然后滚动到某个点,然后返回,然后再返回到chatView,它开始于再顶。 I am allocing the tableView in loadView of the chatView, so the tableView gets realloced everytime I come back.
我在chatView的loadView中分配tableView,因此每次我回来时都会重新分配tableView。 But, isn't this standard?
但是,这不是标准吗? How do I just always scroll to the bottom like the iPhone Messages app and show the scroll bar for a few seconds at the bottom?
如何始终像iPhone Messages应用程序一样始终滚动到底部,并在底部显示滚动条几秒钟?
Here's the code: 这是代码:
http://github.com/acani/acani-chat/blob/master/Lovers2/Classes/ChatViewController.m#L184 http://github.com/acani/acani-chat/blob/master/Lovers2/Classes/ChatViewController.m#L184
Thanks! 谢谢!
Matt 马特
are you doing: 你在做什么:
[self presentViewController:navController animated:YES completion:nil];
where self is tableviewcontroller? tableviewcontroller在哪里? give this a try:
试试看:
[self.navigationController presentViewController:navController animated:YES completion:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.