记录几个还算常用的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

你可能感兴趣的:(记录几个还算常用的Tips,不定期更新)