2015-11-03 90 views
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]; 
} 

这是我用来在我的滚动视图中添加刷新控制器的代码。 但是,当我拉下滚动视图的刷新控制没有显示,目标方法也不是所谓的?UIScrollview拉刷新不起作用

我正在寻找这一段时间,但没有得到任何正确的答案。

一个件事滚动视图有VFL约束一些像这样的事情:

//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]]; 
} 

回答

0

尝试: [self.scrollView insertSubview:self.refreshControl atIndex:0];

检查contentSize它可以小于帧大小,如果所以使用这行代码: self.scrollView.alwaysBounceVertical = true