3
  self.refreshControl = [[UIRefreshControl alloc]init];
    [self.objDiscussiontopic addSubview:self.refreshControl];
    [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];

- (void)refreshTable {
    //TODO: refresh your data
    [self.refreshControl endRefreshing];
}

This is the code i am using to add refresh controller in my scroll view. But when i pull down the scroll view the refresh control is not showing and the targeted method is also not called why ?

I am searching this for a while but didn't get any proper answer .

One more thing scrollview having VFL Constraint some thing like this :

//Pin scrolview to Parent View
    [VFLConstraint allignSubViewViewHorizentallyWithSubView:self.objDiscussiontopic OverSuperView:[self view]];
    [VFLConstraint allignSubViewViewVerticallyWithSubView:self.objDiscussiontopic OverSuperView:[self view] WithTopPading:[CommonFunction convertIphone6ToIphone5:0] AndBotomPading:[CommonFunction convertIphone6ToIphone5:57]];


+ (void)allignSubViewViewHorizentallyWithSubView:(UIView *)subView OverSuperView:(UIView *)superView{

    NSDictionary *viewDict= NSDictionaryOfVariableBindings(subView);
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[subView]|" options:0 metrics: 0 views:viewDict]];
}

+ (void)allignSubViewViewVerticallyWithSubView:(UIView *)subView OverSuperView:(UIView *)superView WithTopPading:(float)topPading AndBotomPading:(float)bottomPading{

    NSDictionary *viewDict= NSDictionaryOfVariableBindings(subView);
    NSDictionary *metrics=[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:topPading],@"topPading",[NSNumber numberWithFloat:bottomPading],@"bottomPading", nil];
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-topPading-[subView]-bottomPading-|" options:0 metrics: metrics views:viewDict]];
}
Raheel Mateen
  • 245
  • 2
  • 13

2 Answers2

3

Try to: [self.scrollView insertSubview:self.refreshControl atIndex:0];

Check the contentSize it can be less that frame size, if so use this line of code: self.scrollView.alwaysBounceVertical = true

pBukhon
  • 46
  • 2
0

I don't think a UIRefreshControl is designed to work with plain scroll views. Apple's docs specifically refer to UITableViews when talking about refresh control.

You can look at third party pull to refresh libraries to add this to UIScrollView

Community
  • 1
  • 1
rounak
  • 9,217
  • 3
  • 42
  • 59