Header Displaced in TableView with UIRefreshControl

前端 未结 5 1065
暗喜
暗喜 2020-12-09 08:33

My UIRefreshController is doing something odd. When I pull-down refresh, the tableView headers are displaced.

If I pull-down it looks fine, but if I scroll down the

5条回答
  •  一生所求
    2020-12-09 08:54

    This could be an issue due to the fact that you are adding _refreshControl as a subview which is not supposed to be done. However you can create a UITableViewController object add it as the child view controller of your current viewcontroller class.

    For eg:-

    UITableViewController *tableViewController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
    [self addChildViewController:tableViewController];
    
    tableViewController.refreshControl = [[UIRefreshControl alloc] init];
    [tableViewController.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    tableViewController.tableView.frame = CGRectMake(...);//set the frame here
    [self.view addSubview:tableViewController.tableView];
    

提交回复
热议问题