iOS错误小结

1.xcode运行到真机报错While reading xx.png pngcrush caught libpng

 原因1. 是提示的png并不是ps导出的png,而是手动修改jpeg后缀名为png,在模拟器上不会报错,但在真机,
不识别这种所谓  的“png”图片。(随便批下美工)
 原因2:这是因为png图片的问题,png图片在存储的时候有一个NOT INTERLACED/INTERLACED(无交错/交错)
的选项,因为设计师在切图的时候的存储错误,图片在XCode中就会报这个错误,但是还是会编译成功并运行,请设计师
将图片重新按无交错存储就行了。
 解决方案:
 用ps重新导出png就ok了
 参考 http://zfanxu.iteye.com/blog/1974113 

The file “XXX” couldn’t be opened because you don’t have permission to view it.
shift+command+k重新运行然后就可以了,我的是这样解决的。

2.AFNetworking报错:(415 Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: un

参考:http://blog.csdn.net/liqunzhang/article/details/70256313

3.Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PhoneCameraController" nib but the view outlet was not set.'

先建的controller类,后加的xib,没有将view与控制器建立关系。
从File's Owner向View拖线。


iOS错误小结_第1张图片
onwer2.png

4、在升级到Xcode9 遇到以下错误:Compiling IB documents for earlier than iOS 7 is no longer supported

将Development Target调整到iOS7以后到版本:


iOS错误小结_第2张图片
屏幕快照 2018-03-21 下午2.52.40.png

5、-(void)scrollViewDidZoom:(UIScrollView *)scrollView不执行

  做scrollView缩放功能时代理设置了,但是self.scrollView.minimumZoomScale = minZoomScale;
  self.scrollView.maximumZoomScale = 1.0f未设置

6、iOS经典错误Undefined symbols for architecture XXX:
原因:编译项目时,因为静态库没有链接进工程,所以静态库就不会参与编译,而项目某些文件(.m文件)又引用(或者说依赖)了静态库,所以自然会报错,而报的错就是经典的 Undefined symbols for architecture XXX这一类的错误。
解决方案:下次遇到这类问题,我们只需要在Linked Frameworks and Libraries 中添加指定的静态库即可!
参考:http://www.cocoachina.com/ios/20170221/18737.html

7、升级完xcode后报错:

error: failed to remove /Users/ ....../xxx.app/Info.plist: “Info.plist” couldn’t be removed.

Command + shift + K就可以了

8、使用百度地图SDK报错:[BMKSearchReverseGeoCodeModel bmk_objectWithKeyValues:]: unrecognized selector sent to class

项目缺少配置
添加官方说明的库及工程配置。


iOS错误小结_第3张图片
image.png
iOS错误小结_第4张图片
image.png

9、百度地图manager start failed : info.plist 中必须添加 Bundle display name

用source code方式打开info.plist并添加:
CFBundleDisplayName
项目名

10、手势与tableview点击事件冲突:

1、父类事件设置代理

UIGestureRecognizer *tapGesture  。。。
tapGesture.delegate = self;

2、覆盖方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return  YES;
}

就可以了

11、

CGImageRef imgRef = self.image.CGImage;
CGFloat w = CGImageGetWidth(imgRef);
CGFloat h = CGImageGetHeight(imgRef);
UIGraphicsBeginImageContextWithOptions(self.image.size, NO, 0);
[self.image drawInRect:CGRectMake(0, 0, w, h)];

绘图时报如下错:

CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SH

最后原因是self.image为nil。

12、Permission to debug xxxx(app) was denied. The app must be signed with a development identity (e.g. iOS Developer).
在用Instruments 测试程序的时候报这样的错。

iOS错误小结_第5张图片
image.png

这里修改Profile 为debug模式解决。

13、 -[__NSCFConstantString size]: unrecognized selector sent to instance 0x10213a758

原因:因为使用时候的类型和初始化的对象类型不匹配造成的。
粗心将字符串直接赋值给了image[self.bottomBtn setImage:@"image" forState:UIControlStateNormal];

改:[self.bottomBtn setImage:[UIImage imageNamed:@"image"] forState:UIControlStateNormal];

14、导入opencv库后报错

Showing All Messages
  "std::__1::num_get > >::id", referenced from:


      std::__1::basic_istream >::operator>>(unsigned long&) in opencv2(persistence.o)


  "std::__1::basic_string, std::__1::allocator >::reserve(unsigned long)", referenced from:


      base64::make_base64_header(char const*) in opencv2(persistence.o)


      icvXMLParseBase64(CvFileStorage*, char*, CvFileNode*) in opencv2(persistence.o)


      icvYMLParseBase64(CvFileStorage*, char*, int, CvFileNode*) in opencv2(persistence.o)


      icvJSONParseValue(CvFileStorage*, char*, CvFileNode*) in opencv2(persistence.o)


  "std::__1::basic_string, std::__1::allocator >::rfind(char, unsigned long) const", referenced from:


      _cvOpenFileStorage in opencv2(persistence.o)


  "typeinfo for std::__1::ios_base", referenced from:


      typeinfo for std::__1::basic_ios > in opencv2(ocl.o)


  "std::__1::locale::locale()", referenced from:
......

添加libc++.tbd解决。

15.运行腾讯云demo报错

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_TXSpeed", referenced from:
      objc-class-ref in VideoEditViewController.o
  "_OBJC_CLASS_$_TXVideoEditer", referenced from:
      objc-class-ref in VideoEditViewController.o
  "_OBJC_CLASS_$_TXPreviewParam", referenced from:
      objc-class-ref in VideoEditPrevController.o
      objc-class-ref in VideoEditViewController.o
.....
      objc-class-ref in ZFPlayerView.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原因
链接的framework不见了,工程本地目录里还在,重新添加framework链接


iOS错误小结_第6张图片
image.png

你可能感兴趣的:(iOS错误小结)