ios---setContentOffset

  UIView * farmeView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.widthself.view.frame.size.height)];

    UITableView * conTentView=[[UITableView alloc] initWithFrame:CGRectMake(0, 110, self.view.frame.size.widthself.view.frame.size.height) style:UITableViewStyleGrouped ];

    conTentView.dataSource=self;

    conTentView.delegate = self;

    conTentView.separatorStyle=UITableViewCellSeparatorStyleNone;

    conTentView.backgroundColor=[UIColor whiteColor];

    conTentView. sectionIndexTrackingBackgroundColor=[UIColor greenColor];

    conTentView.tableHeaderView=[[UIView alloc] initWithFrame:CGRectMake(0, -10, 1, 1)];

    _table=conTentView;

    [conTentView setContentOffset:CGPointMake(0, 230) animated:YES];

 

     [farmeView addSubview:conTentView];

     [self.view addSubview:farmeView];

项目需要,记住上次位置,没有的话(初始化),使用默认位置,可以来点动画呦。

原文地址:https://www.cnblogs.com/wcLT/p/4728643.html