UIRefreshControl的下拉无动画

这应该是个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];    
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,276评论 4 61
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,212评论 25 709
  • 『早安心语』 经营一份事业,不仅仅是为了赚钱,透过这份事业还能够帮助到更多需要帮助的人,让更多的人受益,通过做事,...
    胜者为王王臣森阅读 409评论 0 0
  • 1方法的命名规范 方法的命名规范,C#中有两种命名方法,一种是驼峰命名法,一种是Pascal命名法。 驼峰命名法:...
    a04a42f99657阅读 269评论 0 0
  • 很抱歉,提交晚了。
    经统马姣阅读 152评论 0 0