开发者

Setting contentOffset of UITableView in UIViewController viewDidLoad method doesn't take effect

UITableView setting contentO开发者_高级运维ffset in UIViewController viewDidLoad doesn't take effect...

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    self.tableView.contentOffset = CGPointMake(0.0f, 200.0f);
}

...the value is set, however, after setting an observer on the contentOffset of the table view I can see it is set to zero at least once more after viewDidLoad has run (this is in an empty iphone "table view" template project to ensure its not something I'm doing elsewhere).

I would use viewWillAppear: but that has the effect of losing the position of the users scroll if they are returning back to the controller from elsewhere.

Any ideas? I'm sure this must be simple :)


In viewWillAppear, could you check if the offset is 0,0, and if it is, then set it to where you want it?

That would preserve the user's location while allowing your override.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜