美文网首页
UIRefreshControl的下拉无动画

UIRefreshControl的下拉无动画

作者: 囧书 | 来源:发表于2016-08-04 16:01 被阅读77次

这应该是个Bug,在程序切到后台,再切回来,下拉动画就没了,菊花不转。
有段代码可以尝试修复这个问题,但是只能对TableView的子类有效:

#import <objc/runtime.h>
+ (void)load {    
    Method originMethod = class_getInstanceMethod([UICollectionView class], @selector(setContentInset:));   
    Method newMethod = class_getInstanceMethod([UICollectionView class], @selector(setNewContentInset:));    
    method_exchangeImplementations(originMethod, newMethod);
}
- (void)setNewContentInset:(UIEdgeInsets)contentInset {   
    if (self.tracking) {        
        CGFloat diff = contentInset.top - self.contentInset.top;        
        CGPoint translation = [self.panGestureRecognizer translationInView:self];        
translation.y -= diff * 3.0 / 2.0;       
        [self.panGestureRecognizer setTranslation:translation inView:self];    
    }    
    if ([self respondsToSelector:@selector(setNewContentInset:)]) {       
        [self setNewContentInset:contentInset];    
    }
}

相关文章

网友评论

      本文标题:UIRefreshControl的下拉无动画

      本文链接:https://www.haomeiwen.com/subject/bogcsttx.html