Search code examples
iosobjective-cuitableviewpull-to-refresh

UITableView custom pull to refresh view does not show up


I have the following code for my custom pull to refresh.

CGFloat customRefreshControlHeight = 50.0f;
CGFloat customRefreshControlWidth = 320.0f;
CGRect customRefreshControlFrame = CGRectMake(0.0f,
                                              -customRefreshControlHeight,
                                              customRefreshControlWidth,
                                              customRefreshControlHeight);

TestRefreshView *refreshView = [[TestRefreshView alloc] init];
refreshView.frame = customRefreshControlFrame;
self.testRefreshView = refreshView;

[self.tableView addSubview: self.testRefreshView];

However, this view does not show up when I pull down my table. Is there anything else I need to set up that I am missing?


Solution

  • this is my worked example with custom UIView in UIrefreshController:

    self.refreshControl = [[UIRefreshControl alloc] init];
    self.refreshControl.frame = CGRectMake(x,
                                       y,
                                       self.refreshControl.bounds.size.width,
                                       self.refreshControl.bounds.size.height);
    
    self.animIndView = [[AnimatorIndicatorView alloc] initWithFrame:self.refreshControl.frame];
    
    
    [self.refreshControl addTarget:controller action:@selector(refrechLocation:) forControlEvents:UIControlEventValueChanged];
    [self.refreshControl setTintColor:[UIColor clearColor]];
    
    [controller.refreshControl addSubview:self.animIndView];
    
    [self.tableView addSubview:self.refreshControl];