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