与GMGridView集成时,EGOTableViewPullRefresh不刷新并显示箭头

时间:2013-02-01 09:01:59

标签: iphone ios ios6 uiscrollview

我需要在https://github.com/gmoledina/GMGridView GMGridView中添加一个pull-to-refresh效果! 所以我只是在我的viewController中将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

}

1 个答案:

答案 0 :(得分:1)

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

    _gmGridView.delegate = self;

在viewController的loadView方法中。