您好,欢迎访问一九零五行业门户网

iOS 开发百问(3)

22、解决 messagesent to deallocated instance 0x52cc690 错误
当试图对某个对象进行赋值操作的时候出现这个错误,如:
tfcontent.text=bodytext;
此时,你可以打开nszombieenable选项,则console会有如下输出:
***-[cfstring _isnaturallyrtl]: message sent to deallocated instance 0x52cc690
说明_isnaturallyrtl消息被发送给了一个已经释放了的对象。从上面的语句看,可能是这两个对象:tfcontent、bodytext。
你可以打印tfcontent或者bodytext的内存地址,看看到底是哪个对象已经被释放掉了:
nslog(@"tfcontent:0x%x",(int) tfcontent); nslog(@"bodytext:0x%x",(int) bodytext);
结果表明是bodytext被提前释放:
tfcontent: 0x52cf160 bodytext: 0x52cc690
在适当的地方对bodytext进行retain,问题解决。
23、 putpkt:write failed: broken pipe错误
重启设备。
24、.hfile not found
实际上该.h文件并没有被包含进target。选择对应.m文件,点击“showutilities”按钮(在工具条的右端),在utilities中找到target membership,将target前面的勾去掉,然后再重新勾上。即相当于将该.m文件重新加入target的buildphase中。
25、 xcode 4:如何将for iphone的xib转变为for ipad
在xcode 3.x中,将xib从iphone版转变为ipad版,通过create ipad version菜单。
但在xcode 4.x中,这个菜单找不到了。通过一番摸索,笔者发现可以用如下方法将xib转换为ipad版本。
1、修改xib源文件
xib文件其实是一个xml文件。在project navigator中,在xib文件上右键,选择“open as -> source code”,即可以源代码方式查看xib文件,找到"com.apple.interfacebuilder3.cocoatouch.xib"一行,将其改为 "com.apple.interfacebuilder3.cocoatouch.ipad.xib",即增加了".ipad"。
按下⌘+f,打开搜索栏,点击replace菜单,将模式改变替换模式。将xib文件中所有"ibcocoatouchframework"用 "ibipadframework"替换。
按下⌘+s,保存修改。
2、修改xib的视图尺寸
在xib文件上右键,选择“open as -> interface builder – ios”,用ib模式打开。
选择xib文件中的根视图(uiview),在属性面板中找到size选项,将其改为full ipad screen。
现在,你可以有一个ipad版本的xib了。
26、icon dimensions (0 x 0) don't meet the size requirements.
打开project的buildsettings,找到compress png files,将值设置为no。
或者:
选中该png文件,在fileinspector面板中,找到file type,将其由 "png" 修改为 "icon".
27、警告: noprevious prototype for function
打开target->buildsettings,搜索prototype,将missing function prototypes改为no。
28、coreplot编译时出现 错误“command /developer/platforms/iphoneos.platform/developer/usr/bin/clangfailed with exit code 1”
请将scheme 从 ios device 改为 iphone 5.0 simulator。或者将compiler for c/c++ 改为 llvm gcc4.2。同时,core plot 1.0 不再支持老的 armv6 cpu。
29、使用cabasicanimation改变uiview的alpha值无效
uiview的alpha值,在calayer中其实是"opacity",请使用opcity作为keypath。
30、coreplost:定制 axis label 后,tick mark 不显示。
设置axis 的majorticklocations 为你想显示 tick mark 的位置。
nsmutablearray*customticklocations=[[[nsmutablearray alloc]init]autorelease]; for(int i=0;i<10;i++){ [customticklocationsaddobject:[nsnumber numberwithint:i]]; } xaxis.majorticklocations=[nssetsetwitharray:customticklocations];
31、定制的uitableviewcell, indentationlevel不能生效
需要在定制的uitableviewcell中实现layoutsubviews方法。
- (void)layoutsubviews { [super layoutsubviews]; float indentpoints = self.indentationlevel *self.indentationwidth; for(uiview *view in self.subviews){ view.frame = cgrectmake( view.frame.origin.x+indentpoints, view.frame.origin.y, view.frame.size.width, view.frame.size.height ); } }
以上就是ios 开发百问(3)的内容。
其它类似信息

推荐信息