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

这是我用来在滚动视图中添加刷新控制器的代码。但是当我拉下滚动视图时,刷新控件没有显示,并且目标方法也没有被调用,为什么?

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

具有 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]];
}
4

2 回答 2

3

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

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

于 2016-01-11T10:57:31.603 回答
0

我不认为 aUIRefreshControl旨在与普通滚动视图一起使用。在谈论刷新控制时, Apple 的文档特别提到了UITableViews。

您可以查看第三方拉动以刷新库以将其添加到 UIScrollView

于 2015-11-03T07:27:33.577 回答