自定义xib tableviewcell 无法通过nsdata dataWithContentsOfFile读取的问题

这几天通过xcode 5.1 开发一个自定义的xib tableviewcell,按理说,这种开发是小菜一碟的,然后悲剧就发生了。

cell =[[[NSBundle mainBundle] loadNibNamed:@"CooperationCheckItemCellTableViewCell" owner:self options:nil] objectAtIndex:0];

这一段代码出错,看了一下,这里的loadNibNamed是重写的,不是原来的方法,出错的位置在dataWithContentsOfFile 这个方法,可是看不出什么原因,

于是换了个写法。

NSData *nibData = [NSData dataWithContentsOfFile:localizedNibPath options: 0 error: &error];
    if ([[NSFileManager defaultManager] isReadableFileAtPath: localizedNibPath]  == YES)
        NSLog (@"File is readable");
    else
        NSLog (@"File is read only");
    if (nibData == nil)
    {
        NSLog(@"Failed to read file, error %@", error);
    }

error来了,提示

Failed to read file, error Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x17d53d80 {NSFilePath=/Users/huangymu/Library/Application Support/iPhone Simulator/6.1/Applications/2BACFF4C-2EBA-4268-A3B1-19792D260797/csmobile.app/CooperationCheckItemCellTableViewCell.nib, NSUnderlyingError=0x17d53900 "The operation couldn’t be completed. 权限被拒绝"}

问题在于其他的xib可以被读取,就这个新写的xib不行,比较了一下其他地方tableview的delegate方法,基本都是一样的。怀疑问题出在xib本身,

比较了xib,发现有个选项不同


直觉告诉我可能是这里有问题,改称opensin 4.6

再次编译调试,ok了。所以可能用高版本开发,低版本环境跑存在问题。改低版本开发,就ok了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值