iOS/报错/崩溃bug原因详解集合(一)

来源:互联网 发布:mac 涂层脱落 编辑:程序博客网 时间:2024/05/17 20:23

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的控制器没死时,就要保证创建的控制器不能死。

0 0