setContentOffset仅在动画设置为YES时有效 [英] setContentOffset only works if animated is set to YES
本文介绍了setContentOffset仅在动画设置为YES时有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UITableView,我想显示100px下。由于某种原因,这只有在动画设置为YES时才有效。为什么是这个?
I have a UITableView which I would like to be displayed 100px down. For some reason this only works when animated is set to YES. Why is this?
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
/*[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]
atScrollPosition:UITableViewScrollPositionNone
animated:NO];*/
/*[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndex:1]
atScrollPosition:UITableViewScrollPositionNone
animated:NO];*/
[self.tableView setContentOffset:CGPointMake(0,100) animated:YES];
}
推荐答案
setFrame而不是setContentOffset?
What if you try to use setFrame instead of setContentOffset?
您应该在viewDidAppear方法中添加此代码:
You should add this code in your viewDidAppear method:
[self.tableView setFrame:CGRectMake(0, 100, 320, 380)];
根据视图中的其他元素(例如导航控制器,工具栏等)将必须将380调整为其他值。
Depending on the other elements you have in your view (e.g. navigation controller, tool bar etc.) you will have to adjust the 380 to something else.
这篇关于setContentOffset仅在动画设置为YES时有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文