iOS学习过程中的异常总结

来源:互联网 发布:python 开发框架 编辑:程序博客网 时间:2024/04/30 03:07
没整过这种高级货,还真不知道!
1、删除程序
 长按任意程序图标,等一段时间后,图标左上会出现x 按那个x就可以把程序删除。真机、模拟机都一样。
2、关闭运行中的程序
home按两下,屏幕下方会弹出任务栏,显示了当前运行的程序的图标。长按任意程序图标,等一段时间后,图标左上会出现x 按那个x就可以把程序关闭。真机上试过,模拟机没试。
3、Xcode项目生成文件在哪里?

默认情况下。是有生成,可能你不知道在哪里。

点击旁边的箭头就可跳转到该文件夹。这里不只程序的目标文件,还有其他的生成的文件。

不过,我还遇到一个意外,就是真机上这样跳转没问题,模拟机上却不行,不知道是不是bug,还是别的原因。我的笨办法是将Release-iphoneos前面的路径复制下来,然后在finder里''前往''。

(如果你想在项目中也生成一份,那么就点击Advanced按钮。将Build Location,选择“locations specified by targets”就可以了。

这时你在Build,那么项目路径下就会产生Build目录。---这个网上找的,没试过)。

4、ARC forbids explicit message send of ‘dealloc’

刚开始,真不知道ARC到底是什么,遇到这个问题,还真不知道该咋办。

在iOS SDK 5.0中使用ARC之后,有些东西咱们还是得在对象销毁的时候做,比如说注销Observer什么的,这个时候还是得重写dealloc方法。但是调用[super dealloc]时系统会提示ARC forbids explicit message send of ‘dealloc’,怎么办呢?

根据苹果官方文档(https://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html)的精神,我们无需在重写的dealloc中添加[super dealloc],因为sdk在编译的时候会自己添加上去。

官方文档相关描述如下:

You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC.

Custom dealloc methods in ARC do not require a call to [super dealloc] (it actually results in a compiler error). The chaining to super is automated and enforced by the compiler.

5、iPhone app如何开放一个目录给用户同步?
如何给iPhone传文件,用过iPhone大都知道'' 同步''这个词,不知道的估计也不在少数。作为开发者,又如何让程序允许同步呢?很简单,但是不知道的话也会很纠结:

info.plist文件里有个Application supports iTunes file sharing

设置好之后,就可以使用iTunes 进行同步了。


6、'text' is deprecated: first deprecated in iOS 3.0解决办法

原来是这样的:

self.RecentCell.text = [self.itemsobjectAtIndex:0];

改为这样的:

[[self.RecentCelltextLabelsetText:[self.itemsobjectAtIndex:0]];

7、调用包含c++代码的静态库的时候出现 Apple Mach-O Linker Error

将编译选项里的'' compile source as'' 设置为''object c++  '' 


8、使用CGContextDrawImage绘制图片上下颠倒

那是因为在iOS的不同framework中使用着不同的坐标系 :
UIKit - y轴向下
Core Graphics(Quartz) - y轴向上
OpenGL ES - y轴向上

原创粉丝点击