zoukankan      html  css  js  c++  java
  • IOS错误笔记(二)-------常见错误【转】

    1. mutating method sent to immutable object'

    从字面上理解:可变的消息发给了不可变的对象。比如NSDictionary类型的对象调用setValue方法.应该把NSDictionary 改成NSMutableDictionary类型。

     

    2.Local declaration of 'content' hides instance variable

     

    一般是函数里面定义的变量和class属性变量重名了。很少有和系统变量重名的情况。

     

    3.unrecognized selector sent to instance 

    大部分情况下是因为对象被提前release了,在不希望他release的情况下,指针还在,对象已经不在了。

    很多时候,是因为init初始化函数中,对属性赋值没有使用self.foo赋值,而是直接对foo赋值,导致属性对象没有retain(心里以为retain了),而提前释放。

    4.使用ASIHTTPRequest编译不通过

    原因是一些类库没有加进去。把这些库加进去CFNetwork, SystemConfiguration, MobileCoreServices, and libz.dylib

    5.添加在UIView中的UIButton   单击不起作用

    原因是UIbutton的frame超出了UIView的frame范围。事实上UIView并没有设置frame,设置完后( 范围一定要在UIButton之外),UIButton单击就可以了

    6.当使用presentViewController和dismissPresentViewController时,如果报这个错 : while  presentation is in progress ,修改方法为[mainView dismissModalViewControllerAnimated:NO];  将参数Animated改为NO;如果报这个错while a presentation or dismiss is in progress,试试这样

     if (![[mainView modalViewController] isBeingDismissed]) {
            [mainView dismissModalViewControllerAnimated:NO];
        }
    7.调用系统相册的时候,非常容易出现内存警告,加入红色代码就会好点:

     
            UIImagePickerController * picker = [[UIImagePickerController alloc]init];
            picker.delegate = self;
            picker.allowsEditing = NO;  //是否可编辑
            picker.videoQuality=UIImagePickerControllerQualityTypeLow;
            //摄像头
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentModalViewController:picker animated:YES];
            [picker release];


    8.ios开发者都遇见过得错误:EXC_BAD_ACCESS 。这个和第二个比较类似。通常的调试方法就是加入NSZombieEnabled变量,加入方法自行百度。

    并且开发过程中使用

     [[NSNotificationCenterdefaultCenter]

    来发布本地消息,这个也经常会出现EXC_BAD_ACCESS错误。这个时候只需要在你的view活着viewControllers的dealloc的方法里面加入

    [[NSNotificationCenterdefaultCenter]removeObserver:selfname:@"yourNotification"object:nil];就ok了

    9.遇见一个蛋疼的问题"linker command failed with exit code 1 (use -v to see invocation)" 。翻遍了找不到原因。然后还有这样的警告

    duplicate symbol _OBJC_CLASS 。原来是在导入某个类的时候导入.m文件,而不是.h文件惊恐

  • 相关阅读:
    System.Web.HttpException: 应用程序已预编译,因此不允许使用目录“/App_Code/”。
    ASP.NET导出Excel文件
    简单易学的OA报表
    input添加邮箱的时候自动显示后缀
    Sql Server中存储过程执行很快,但程序调用时执行非常慢的问题(连接超时)
    C#如何卸载已安装的Windows Service服务
    CSS专题(二):元素大小与位置offsetLeft offsetTop offsetWidth offsetHeight clientWidth clientHeight scrollWidth scrollHeight scrollLeft scrollTop
    Eclipse maven构建springmvc项目
    49个jQuery代码经典片段
    CSS专题(一):Background
  • 原文地址:https://www.cnblogs.com/fsliu/p/4243446.html
Copyright © 2011-2022 走看看