0

我需要在https://github.com/gmoledina/GMGridView GMGridView 中添加拉动刷新效果!所以我只是在我的视图控制器中将 GMGridView 与 EGOTableViewPullRefresh 集成,但事实证明没有新鲜效果,并且当我拉出 refreshHeaderView 时不显示向上箭头。以下是我的 viewController 中的一些代码片段:

- (void)loadView
{
    [super loadView];

    self.view.backgroundColor = [UIColor whiteColor];
    NSInteger spacing = INTERFACE_IS_PHONE ? 5 : 15;

    GMGridView *gmGridView = [[GMGridView alloc] initWithFrame:self.view.bounds];
    gmGridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    gmGridView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:gmGridView];
    _gmGridView = gmGridView;

    _gmGridView.style = GMGridViewStyleSwap;
    _gmGridView.itemSpacing = spacing;
    _gmGridView.minEdgeInsets = UIEdgeInsetsMake(spacing, spacing, spacing, spacing);
    _gmGridView.centerGrid = YES;
    _gmGridView.actionDelegate = self;
    _gmGridView.sortingDelegate = self;
    _gmGridView.transformDelegate = self;
    _gmGridView.dataSource = self;

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (_refreshHeaderView == nil) {

        EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.gmGridView.bounds.size.height, self.view.frame.size.width, self.gmGridView.bounds.size.height)];
        view.delegate = self;
        [self.gmGridView addSubview:view];
        _refreshHeaderView = view;
        [view release];

    }
    [_refreshHeaderView refreshLastUpdatedDate];
}


- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];

}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

    [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];

}

- (void)reloadTableViewDataSource{

    //  should be calling your tableviews data source model to reload
    //  put here just for demo
    _reloading = YES;

}

- (void)doneLoadingTableViewData{
    _reloading = NO;
    [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.gmGridView];

}


- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{

    NSLog(@"egoRefreshTableHeaderDidTriggerRefresh");
    [self reloadTableViewDataSource];
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];

}

- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{

    NSLog(@"egoRefreshTableHeaderDataSourceIsLoading");
    return _reloading; // should return if data source model is reloading

}
- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{

    return [NSDate date]; // should return date data source was last changed

}
4

1 回答 1

1

我已经解决了这个问题:需要让 viewController 确认 UIScrollViewDelegate 并添加

    _gmGridView.delegate = self;

在 viewController 的 loadView 方法中。

于 2013-02-01T11:40:44.827 回答