关于 IOS 开发中遇到的 读取 cell xib 文件时导致死机的问题。
2013-03-29 00:07
645 查看
下面这句话看上去没有什么问题,但是偏偏在这个地方APP crash了。
cell = [[[NSBundlemainBundle]
loadNibNamed:CellIdentifierowner:selfoptions:nil]lastObject];
在google.ca,搜索了下: loadNibNamed crash . 得到了这样的一条关键信息: http://stackoverflow.com/questions/5479684/crash-on-nsbundle-mainbundle-loadnibnamedowneroptions
这里面的一条关键的回复:
The
problem is that you connected the labels to the File's Owner, but when you call loadNibNamed..., you pass nil as the file's owner. You should connect the labels to the cell object in the nib. initWithStyle: will not be called when loading from a nib. Nib loading
uses initWithCoder: to initialize the object and calls awakeFromNib after the nib is loaded.
事实上是由于我之前的误操作:把所有的view 都关联到了 file's ower. 然后通过 file's ower 关联到对应的 IBOutlet 属性。这样做法是有问题的:
当调用了 loadNibNamed ,其中就有个参数, owner:self 这样将直接导致这个 self 与 xib 的 file's owner 不是同一个概念的。所以将直接导致死机。
正确的做法应该是这样:
取消所有xib与file's owner 关联。
直接关联到对应的属性上。
这样就可以了。然后重新编译运行下。问题解决。
cell = [[[NSBundlemainBundle]
loadNibNamed:CellIdentifierowner:selfoptions:nil]lastObject];
在google.ca,搜索了下: loadNibNamed crash . 得到了这样的一条关键信息: http://stackoverflow.com/questions/5479684/crash-on-nsbundle-mainbundle-loadnibnamedowneroptions
这里面的一条关键的回复:
The
problem is that you connected the labels to the File's Owner, but when you call loadNibNamed..., you pass nil as the file's owner. You should connect the labels to the cell object in the nib. initWithStyle: will not be called when loading from a nib. Nib loading
uses initWithCoder: to initialize the object and calls awakeFromNib after the nib is loaded.
事实上是由于我之前的误操作:把所有的view 都关联到了 file's ower. 然后通过 file's ower 关联到对应的 IBOutlet 属性。这样做法是有问题的:
当调用了 loadNibNamed ,其中就有个参数, owner:self 这样将直接导致这个 self 与 xib 的 file's owner 不是同一个概念的。所以将直接导致死机。
正确的做法应该是这样:
取消所有xib与file's owner 关联。
直接关联到对应的属性上。
这样就可以了。然后重新编译运行下。问题解决。
相关文章推荐
- iOS 开发关于.pch文件问题
- iOS开发遇到memory持续上涨导致页面crash问题解决思路
- iOS开发遇到的错误 -- Label显示多行文字导致宽度和高度的问题
- 关于ios开发中遇到thread 1:exc_bad_access(code=1,address=0x50000010)类似的问题
- 学习安卓开发过程中遇到关于R.Java文件的问题
- 关于IOS 开发遇到的问题,Code 126 Copy Pods Resource
- 【iOS开发问题】使用NSCoding写入本地文件读取不出来或者文件没有写入本地
- 关于读取CocoStudio的ui文件可能遇到的问题
- 开发中遇到的关于classnotfound和resource文件找不到和getresource的路径问题
- iOS开发中遇到的头文件找不到的问题解决办法
- iOS开发 -关于使用iOS沙盒路径遇到的问题
- iOS随笔记-开发中遇到的#import头文件找不到的问题解决办法
- Android开发过程中遇到的关于so文件的问题
- 关于CSV文件导入到数据的方法以及遇到的问题和解决方案
- iOS开发中关于import头文件放置位置的tips
- iOS开发-使用UIImagePickerController遇到的问题
- 【Android开发经验】关于主题引用混乱导致程序运行崩溃的问题
- 关于javascript从txt文件中读取内容出现乱码的问题
- PHP file函数读取文件遇到<***>时的奇怪问题
- 关于APICloud开发iOS出现不全屏问题