UIRefreshControl not showing indicator or title?

I want to implement Pull To Refresh in UITableViewControllerusing UIRefreshControl. Here is what I have tried so far.

 - (void)viewDidLoad
    {
     .....
     ////********* Pull to refresh ************/
        UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
        refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
        refresh.tintColor = [UIColor magentaColor];
     //   [self.tableView addSubview:refresh];
// [self.refreshControl setEnabled:YES];
        [refresh addTarget:self action:@selector(pullToRefresh:) forControlEvents:UIControlEventValueChanged];
        self.refreshControl = refresh;

    }
    -(void)pullToRefresh:(UIRefreshControl *)refresh {
         [refresh beginRefreshing];
        refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Refreshing.."];
        [self loadRecentActivities];
    }

But when I pull out the table view, neither the activity indicator nor the title are visible, however the pullToRefreshtable is called and updated. My application supports iOS7.0 + . What am I missing? Any help would be appreciated?

Edit: I tried with [self.refreshControl setEnabled:YES];and [self.refreshControl setEnabled:YES];, as mentioned in my edited code, but still no luck. This is what my table view looks like when I pull it out for an update -enter image description here

Final Solution: For the table table background I used

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
self.tableView.backgroundView = imageView;

self.tableView.backgroundView,

[self.tableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];

. Balram Tiwari, , . , .

+4
2

View, . ( -, ). ,

iOS7, UIViewController (edgesForExtendedLayout). , (0,0) .

, tableView . , edgesForExtendedLayout viewController viewDidLoad.

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

.

  • :

Before fix

  • .

After the fix

, .

+7

self.tableView.backgroundView.layer.zPosition -= 1; refreshControl.

+11

Source: https://habr.com/ru/post/1527269/


All Articles