常见问题(二)

目录

  1. 程序卡在某个界面不动
  2. Multiple commands produce问题
  3. YYLabel 不显示
  4. performSelector:withObject:afterDelay:最好成对出现

1. 程序卡在某个界面不动

如果内存不高, 往往是线程死锁引起的, 可以点击 Xcode 的 "Pause program execution" 按钮


1156675-3e30cf93941fd7ab.png
莫名卡死@2x.png

show the debug navigator 页面查看当前线程的使用情况

1156675-b18c4d27e0416ad3.png
线程分析.png

可以看出是在添加 ijkplayer 的时候出现的问题.

2. Multiple commands produce问题

错误问题简化如下:

Showing Recent Messages :-1: Multiple commands produce '.../Info.plist': 1) Target 'UserHomepageBaseView' (project 'UserHomepageBaseView') has copy command from '.../JHChainableAnimations/Info.plist' to '.../Info.plist' 2) Target 'UserHomepageBaseView' (project 'UserHomepageBaseView') has copy command from '.../Network/Info.plist' to '.../Info.plist' 3) Target 'UserHomepageBaseView' (project 'UserHomepageBaseView') has process command with output '.../Info.plist'

可以看到 JHChainableAnimations 和 Network 的 info.plist 文件的问题, 解决方案如下:
根据提示信息,选中对应的target-> Build Phases -> Copy Bundle Resource -> 移除所有Info.plist

3. YYLabel 不显示

  1. 只要 YYLabel 的宽高比需要的宽高小, 就会导致文字显示不全的问题.
  2. 如果 YYLabel 的四个约束没有全部确定好, 也会不显示.
  3. YYLabel 最擅长在富文本中加载图片等附件, 普通的文本字符, 最好直接用 UILabel.

4. performSelector:withObject:afterDelay:最好成对出现

  1. 在使用 performSelector:withObject:afterDelay: 对象方法后, 一定要在 dealloc 中 使用 cancelPreviousPerformRequestsWithTarget 类方法来停止掉延迟执行的方法
  2. 在使用 performSelector:withObject:afterDelay: 对象方法前, 最好也使用cancelPreviousPerformRequestsWithTarget 类方法来防止重复的操作.

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(removeGiftPkView) object:nil];
[self performSelector:(@selector(removeGiftPkView)) withObject:nil afterDelay:5];

猜你喜欢

转载自blog.csdn.net/weixin_34273481/article/details/87528342