iOS/------报错问题集合(一)-------------------------------------

 

1.原因:应用程序试图在LoginViewController上模态出一个空的视图控制器。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <LoginViewController: 0x7fc692e0d300>.'

 

2.一个navigationController不能pushnavigationController,可以presentnavigationController

  只有navigationController才能用push方法;

 

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'

 

 3。应用程序需要一个启动控制器,(查看工程---Deployment--main interface如果不是加载的mainstoryBoard中的控制器,把main删掉;如果自己新建的storyBoard,查看箭头有没有指向要加载的控制器)

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

 

4..不允许在隔离的控制器上present出一个控制器

. Presenting view controllers on detached view controllers is discouraged <LeftSortsViewController: 0x7fbccb525540>.

 

5,约束问题

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with items <UIButton: 0x7f909150fb50; frame = (0 0; 0 0); opaque = NO; layer = <CALayer: 0x7f909150fdf0>> and <UIView: 0x7f9091745800; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7f909173ffa0>> because they have no common ancestor.  Does the constraint reference items in different view hierarchies?  That's illegal.'

 

 

*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs'

 

 

6,不允许模态出一个已经在前台的控制器()

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <MainTabBarController: 0x7fe7c3050800>.'

 

 

7.链接问题,有重名的文件

 

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

 

8.属性命名不能有关键字.不能以new开头

 

 

9.scrollView 中添加控制器的view;

   问题: 程序 一运行 就像 线程阻塞一样卡死 十几秒后 崩溃

  解决:将控制器的view直接添加到scrollerview的view上,不过需要注意的是在scrollerView中创建控制器时一定要强引用这个控制器,也就是说scrollerView的控制器没死时,就要保证创建的控制器不能死。

 

10.在viewDidLoad里面调用

presentViewController:self.browseranimated:YEScompletion:会不起作用,并且提示: whose view is not in the window hierarchy;

 

11.把A控制器添加到B控制器,就相当于吧A控制器的view添加到B控制器的view中,这里要注意在interface中吧A控制器添加strong强引用;否则不起作用;

 

12.当你从别人那拿到一个项目,放到自己电脑上需要重新sign,如果现实签名无效,就把automatically manage signning 勾选上;

如果还是出现如下红框2的报错:说明我的苹果账号7天创建了超过10个bundle IDentifier;这时可以吧bundle IDentifier改成以前的。

 

13.NSSetUncaughtExceptionHandler

iOS SDK中提供了一个现成的函数 NSSetUncaughtExceptionHandler 用来做异常处理,但功能非常有限,而引起崩溃的大多数原因如:内存访问错误,重复释放等错误就无能为力了,因为这种错误它抛出的是Signal,所以必须要专门做Signal处理。首先定义一个UncaughtExceptionHandler类,.h头文件的代码如下:

#import <UIKit/UIKit.h>

@interface UncaughtExceptionHandler : NSObject

{

BOOL dismissed;

}

@end

=======================

 

 

#import "AppDelegate.h"

 

 

void InstallUncaughtExceptionHandler()

 

{

signal(SIGABRT, MySignalHandler);

signal(SIGILL, MySignalHandler);

signal(SIGSEGV, MySignalHandler);

signal(SIGFPE, MySignalHandler);

signal(SIGBUS, MySignalHandler);

signal(SIGPIPE, MySignalHandler);

}

 

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

 

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   在地点finishapplication:方法中调用 NSSetUncaughtExceptionHandler(&InstallUncaughtExceptionHandler);

//异常处理--产生异常就会调用InstallUncaughtExceptionHandler函数

}

这样,当应用发生错误而产生上述Signal后,就将会进入我们自定义的回调函数MySignalHandler。

 

14.sign证书问题;------先把钥匙串打开,可以把automatically sign前面的勾去掉再勾上试试,或者在钥匙串中删掉证书。

 

The certificate used to sign "GPUIMageTest" has either expired or has been revoked. An updated certificate is required to sign and install the application.

 

15. -fembed-bitcode is not supported on versions of iOS prior to 6.0

 

 

16.需要在info。plist中设置private权限。

 

This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

 

17.iOS屏幕显示上下有空白-----------------解决办法:缺少合适的启动图片,吧launchImage设置一下;

 

 

 

18.self.title不起作用-------------------------可能在tabBarController的外层包了一层导航控制器,这个导航控制器作为window的根控制器;导致这个导航控制器的导航栏吧ta bBarController子控制器的导航栏遮挡了,所以self.title设置无效;
当tabBarController中的子控制器直接是导航控制器(不是viewcontroller外面包装导航控制器的那种),添加导航标题时用下面的方法:
    UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width*0.5-10, 10, 60, 30)];
    lbl.text=@"发现";

 

    [self.navigationBar addSubview:lbl];

 

 

19===========.AFNetworking报错:请求出来的数据是一大堆16进制数据,原因后台数据不规范,不是json格式的数据;

 

failureBlock :Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set., NSUnderlyingError=0x618000247440 {Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x610000033f60> { URL: http://shop.ahwofu.com/index.php?m=Api&c=Index&a=homePage } { status code: 404, headers {

    Connection = "keep-alive";

    "Content-Encoding" = gzip;

    "Content-Type" = "text/html; charset=utf-8";

    Date = "Tue, 18 Apr 2017 02:10:59 GMT";

    Server = "nginx/1.4.4";

    "Transfer-Encoding" = Identity;

    Vary = "Accept-Encoding";

    "X-Powered-By" = "PHP/5.5.7";

} }, NSErrorFailingURLKey=http://shop.ahwofu.com/index.php?m=Api&c=Index&a=homePage,

 

 

 

 responseSerializer 使用 AFHTTPResponseSerializer,这样就不能享受 AFNetworking 自带的JSON解析功能了,拿到 responseObject 就是一个 Data 对象,需要自己根据需要进行反序列化。
 
NSString *reponStr = operation.responseString; NSData* data=[reponStr dataUsingEncoding:NSUTF8StringEncoding]; id dict=[NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; NSLog(@"获取到的数据为:%@",dict);

 

 

 

 

 

==========数组未初始化

 

invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

libc++abi.dylib: terminate_handler unexpectedly threw an exception

 

=================tag值混乱,不知道点击的是哪一个

 

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString aUsername]: unrecognized selector sent to instance 0xa0000006973696c4'

 

============tableview cell 的服用的IDdentifier没找到,导致没有可用的cell;

 

*** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:6245

 

========

Failed to chmod user/Library/Developer/CoreSimulator/Devices NO Such File Or directory
  • 1
  • 1

 

最后只好找度娘了….说reset 一下模拟器就好了…就是这样Simulator -> Reset Content and Settings...,,,试了一下…还真可以…当然,如果还不行的话,,就重启 Xcode,,,, 再不行,,,就重启电脑吧….

=======WF: _WebFilterIsActive returning: NO==========ios10以上改成MKWebview就可以了;

===========Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:]

cell 没有找到,建议看看布局是否完整,identifier设置的是否正确;

 

 ====证书过期======重新automatically manage sign

 

====

"_OBJC_CLASS_$_XXX", referenced from:

原因:缺少文件,或文件我参与编译,framework 没导入,真机和测试也要注意,.m文件为参与编译

解决:在build Phases->Compile Sources 中添加相应的类文件

 

 

===========点击textfield弹出键盘时崩溃

Can't find keyplane that supports type 5 for keyboard iPhone-PortraitChoco-PhonePad; using 2024220450015396792_PortraitChoco_iPhone-Complex-Pad_Default

 

解决办法:

 

=====

linker command failed with exit code 1解决方案

解决方案:http://colabug.com/172588.html

 

1,看看是不是有新添加的文件跟之前文件同名

 

2,错误信息中出现了某个类的名字,去原文件中看看#import了哪些第三方库,把这些库挨个注释排除,找到出错的那个库,然后按照官方提供的步骤重新添加一遍。

3.SVN或git忽略了某些文件,如.o 等文件没能update下来,查看.o文件可能是红色的,可以重新添加或者修改SVN(git)的忽略设置

4.把.a文件删除再重新拖到项目中解决问题

5.可能重复添加了文件(也可能没勾选 Copy items if neded 这个选项),建议删除后重新添加

6.工程中文件名重复了 也会出现同样的错误

7.”Build Settings”->”Enable Bitcode”设置为NO ,因为有些SDK不支持Bitcode

8.可能在引用的时候 可能写的是#import “XXXXX.m” ,如果是改为#import “XXXXX.h”

9.可能你导入的SDK只能在真机下才能运行,模拟器会报错!

10.找到 Build settings->Linking->Other Linker Flags将此属性修改成-all_load 或者 -ObjC

11.Build settings->Search Path->Library Search Paths 添加静态库的相应路径

 

=====

invalid bitcode signature解决方案

解决:换真机试一试;

 

========Terminating since there is no system app.

webView返回崩溃:返回的上一级页面如果是Tableview,cell上的图是从网络实时下载的,如果图片太大,可能会崩掉哦

 

============= 报错,真机运行报错

 

Showing Recent Issues CodeSign /Users/wofu/Library/Developer/Xcode/DerivedData/wofubao-gwycsluotlqifyfgppjkhmfwwurg/Build/Products/Debug-iphoneos/wofubao.app     cd /Users/wofu/Desktop/ios-2/2号钱包/Wofubao     export CODESIGN_ALLOCATE=/Applications/Xcod

解决:先退出xcode,再把/Users/appleapple/Library/Developer/Xcode/DerivedData/下面的东西都删除(DerivedData本身不要删),再启动xcode,再rebuild. 

 

=====xcode爆出"Command /usr/bin/codesign failed with exit code 1"这样一个错

解决办法:

当时以为是授权文件设置不正确的问题,于是从开发者账户上重新下载授权文件进行了安装,。。。不好使,后来想了想,可能是存在两个相同授权文件的问题(一个用过期证书)

打开Xcode->Preferences->Account,选择你开发者账户,在右下侧选择View Details,在Provisioning Profiles一栏,果然发现了两个一样名字的授权文件,一个是过期的,一个是正在用的,把两个删掉,再重新安装最新的授权文件,OK了,标注一下,省的以后忘记了

 

=======push出去的时候出现卡顿的解决办法:

从普通控制器push出去:解决---

 //加上这个在主线程异步就不卡顿了

            dispatch_async(dispatch_get_main_queue(), ^{}

 

从cellpush出去:解决

http://blog.csdn.net/gang544043963/article/details/48656545

 

首先,在tableview的didSelectRowAtIndexPath:方法中有push控制器:

 

[objc] view plain copy

  1. [self.navigationController pushViewController:assetsVc animated:NO];  


一般情况下push控制器没什么问题,关键在于,在assetsVc控制器中有一个动作执行需要800ms时间。

 

经过测试,把这个耗时的方法分别放在viewDidLoad、viewDidAppear里面,tableview均会卡顿。

问题思考:assetsVc里面的耗时操作为什么会使tableview卡顿?

 

经过试验发现,从tableview向assetsVc的页面跳转动作发生在assetsVc页面加载完成之后,也就是说,在assetsVc执行完viewWillLoad、viewDidLoad、viewWillAppear、viewDidAppear、viewWillLayoutSubviews、viewDidLayoutSubviews之后,页面才会跳转。

 

解决办法:

为了提升用户体验,让刚才说的耗时操作异步执行就可以了。

 

=======UITableview报错

Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.21.8/UITableView.m:9373

原因:没有注册cell;

解决:注册cell或者在cellforRow中判断实例化cell;

 

===========报错 

Lazy loading NSBundle MobileCoreServices.framework, Loaded MobileCoreServices.framework, System gr

解决:http://blog.csdn.net/qq_31448571/article/details/78533662

 

============报错

iOS:Error Domain=WebKitErrorDomain Code=101 "The operation couldn’t be completed. (WebKitErrorDomain

解决

NSString *urlStr = [NSString stringWithFormat:@"%@?uid=%@&uname=%@",KQuestionnaireUrl,model.idStr,model.real_name];

urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURLURLWithString:urlStr];

NSURLRequest *request = [[NSURLRequestalloc]initWithURL:url];

[webView loadRequest:request];

 

 

webView无法加载包含中文URL,转码编译即可

 

============

xcode报错 xxx file not found 解决办法

这种问题引起的原因往往是导入了包,但是没有配置Framework Search Path所导致的。Framework Search Path的作用就是让xcode按照你给的路径去找到第三方库所在的位置。如果你不配置,就会报file not found。 

 

这里是个坑,很多人遇到这种问题,不知道怎么解决。下面说下解决办法以及需要注意的事项:

1 点击xcode工程的项目名,然后在targets里点击Build Setting,然后找到Search paths,就可以看到Framework Search Path。

2 选中按回车建,或者tab键就可以编辑了,双击也可以编辑,点击+号添加就可以。

3 添加第三方库注意一点,有两种方式,一种是相对路径,一种是绝对路径。绝对路径适合就你一个人开发,相对路径在团队协作的时候我们一定要用。

按照上面步骤把第三方库路径添加进去后,再编译下xcode,发现一切都正常了。

检查Header Search Path、Library Search Path、FrameWork Search Path

 

****模拟器debug模式可以运行,模拟器release模式不可以运行,真机release模式可以运行;

解决:build setting-》build Active Architecture Only 吧Debug和Release都改成YES;

 

***ios开发出现Undefined symbols for architecture xxx问题的解决办法

https://blog.csdn.net/huaqishen123/article/details/80609800

 

 

******报错

如果一个项目以前是手动设置的签名证书,当设置为自动模式时,有时就会出现以下的错误:

XXX is automatically signed, but provisioning profile YYY has been manually specified. Set the provisioning profile value to “Automatic” in the build settings editor, or switch to manual signing in the project editor.
其中XXX是项目名称,YYY是一串字符。

解决:

找到工程目录,注意选择的文件啊,不是cocoaPods配置的工作空间.xcworkspace文件, 而是原始的项目.xcodeproj文件!右键显示包内容,

打开project.pbxproj文件,搜索关键字:PROVISIONING_PROFILE ,注意这里面会有好些PROVISIONING_PROFILE文件,注意选择!然后删除这句“PROVISIONING_PROFILE = "b257564f-9d82-4034-87a3-18a0d4029e73"”,

https://www.jianshu.com/p/c899d98f626e

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值