记录几个还算常用的Tips,不定期更新

  • 删除文件夹下所有.svn文件
    find . -name ".svn" | xargs rm -Rf
  • 删除文件夹下所有.git文件
    find . -name ".git" | xargs rm -Rf
  • 防止UILabel被压缩或被拉伸
 [label setContentHuggingPriority:UILayoutPriorityRequired
                           forAxis:UILayoutConstraintAxisHorizontal];
[label setContentCompressionResistancePriority:UILayoutPriorityRequired 
                                         forAxis:UILayoutConstraintAxisHorizontal];
  • 滑动时若不希望Timer被ScrollView影响,需添加到NSRunLoopCommonModes
RunLoopMode:
  • NSDefaultRunLoopMode : 默认状态、空闲状态
  • UITrackingRunLoopMode : 滑动ScrollView时
  • UIInitializationRunLoopMode : 私有,App启动时
  • NSRunLoopCommonModes : 集合于1和2
NSTimer *timer = [NSTimer timerWithTimeInterval:1.0
                                           target:self
                                         selector:@selector(timerTick)
                                         userInfo:nil 
                                          repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer 
                               forMode:NSRunLoopCommonModes];
  • UITableView延迟加载图片,防止滑动时卡顿
UIImageView *imageView = [[UIImageView alloc] init];
UIImage *image = [UIImage imageNamed:@"imageIcon"];
[imageView performSelector:@selector(setImage:)
                  withObject:image
                  afterDelay:0
                     inModes:@[NSDefaultRunLoopMode]];
  • 解决CG Raster Data内存占用问题
https://github.com/waynezxcv/Gallop/issues/34
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容