プルアップリフレッシュ

2213 ワード

塩漬けの魚の上で引き延ばして更新します
#pragma mark -     
#pragma mark            (       )
- (void)prepare
{
    [super prepare];
    
    //        
    self.mj_h = 50;
    
}

#pragma mark               
- (void)placeSubviews
{
    [super placeSubviews];
    
}

#pragma mark   scrollView contentOffset  
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];
    
}

#pragma mark   scrollView contentSize  
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark   scrollView       
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];
    
}


#pragma mark          
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    
    
    switch (state) {
        case MJRefreshStateIdle:
            
            
            [self dismissActivity];
            break;
        case MJRefreshStatePulling:
            
            
            break;
        case MJRefreshStateRefreshing:
            
            
            
            [self showActivityView];
            break;
        default:
            break;
    }
}

- (void)showActivityView {
    
    if (!_activityImageView) {
        
        UIImageView *activity = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 52, 16)];
        _activityImageView = activity;
        activity.center = CGPointMake(self.mj_w * 0.5, self.mj_h * 0.5);
        [self addSubview:activity];
    }
    
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=29; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"loading_v1_%05lu", (unsigned long)i]];
        [refreshingImages addObject:image];
    }
    
    _activityImageView.animationImages = refreshingImages;
    _activityImageView.animationDuration = 1.0f;
    _activityImageView.animationRepeatCount = 100;
    [_activityImageView startAnimating];
    
}

- (void)dismissActivity {
    
    [_activityImageView stopAnimating];
    [_activityImageView removeFromSuperview];
    _activityImageView = nil;
}