是否有可能在uicollectionview中下拉刷新并加载自定义集合单元格中的更多内容?

时间:2013-11-09 06:39:25

标签: ios

我尝试下拉以在集合视图中刷新,但我使用(tableview下拉刷新控制器)相同的代码集合视图。请任何人帮我解决问题。

1 个答案:

答案 0 :(得分:1)

首先,您可以在viewDidLoad中编写此代码: -

- (void) viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];

    refreshControl.tintColor = [UIColor blackColor];

    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];

    [refreshControl addTarget:self action:@selector(refreshControlAction) forControlEvents:UIControlEventValueChanged];

    [collectionView addSubview:refreshControl];
}

 Now add a target

- (void) refreshControlAction
{
    // Enter your code for request you are creating here when you pull the collectionView. When the request is completed then the collectionView go to its original position.
}