1.iphone之xx_Prefix.pch的作用和用法

     Prefix.pch:扩展名.pch表示"pre-compiled-header",这是一个你工程要用到的 来自于外部框架的头文件列表。xcode将编译这些头到文件,这将减少你在选择Build或Build and Go时编译项目的时间。通常用到的头文件已经自动包含了

pch,系统编译每个.m文件前,都会先import这个文件。这样既节省了你手动添加import的时间,也有助于加速编译.

还有就是可以在这里面放入宏,在整个工程中都可以用。节省了时间

2.iphone之发布版本的时候移除NSLog输出的方法

只需要将下列代码加入到pch文件中即可, __OPTIMIZE__这个编译选项是发布版本才有的,所以在编译调试版本的时候可以看到Log,而发布版本则没有Log。

#ifndef __OPTIMIZE__

#define NSLog(...) NSLog(__VA_ARGS__)

#else

#define NSLog(...) {}

#endif

3.iphone之取消icon的高光状态

系统会默认会在图标上 自动加上半透明的高光半圆,如果我们不想要这个效果或者图标本身已经包含了这个高光效果,我们可以在项目配置里把系统的高光功能取消掉:

xcode3.2x建的项目:

在info plist里加一个配置项,key为“Icon already includes gloss and bevel effects”, 类型为bool,然后打上钩就,这样系统就不会自动加高光;

xcode4建的项目:

在项目target的summary标签页下找到App Icons项,在“Prerendered”打上钩
 

 
此时在info.plist里会多出一个配置项" Icon already includes gloss effects":

 
再找到 “Icon files (iOS 5)”项目(如果有的话),展开, 把里面的“Icon already includes gloss effects”也设置成“YES”:

这样程序中的高光效果就取消了。

4.iphone之unichar和初始化

在iphone/mac开发中,unichar是两字节长的char,代表unicode的一个字符。但在xcode中,初始化unichar是个问题。如果像下面这样声明,会有warning"Multi-character character constant"。

unichar a = '国';

这是因为C语言中两个单引号只能用于char。可以采用直接写文字编码的方式来初始化。

unichar a = 0x0100;

如果有很多个unichar怎么办?一个个去查表太麻烦了。可以采取变通的方法:

unichar a[10];

NSString *aString = @"一二三四五六七八九十";

for (int i = 0; i < 10; i++)

a[i] = [aString characterAtIndex:i];

5.iphone之转向appstore中商品

NSString *str =@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware? id=473898949";

[[UIApplication sharedApplication] openURL:[NSURLURLWithString:str]];

把"id=3410863403"换成id=xxxx(自己程序的ID),即可。

6.iphone之iphone控件尺寸

Element Size (in points)
Window (including status bar) 320 x 480 pts
Status Bar
(How to hide the status bar)
20 pts
View inside window (visible status bar) 320 x 460
Navigation Bar 44 pts
Nav Bar Image /Toolbar Image up to 20 x 20 pts (transparent PNG)
Tab Bar 49 pts
Tab Bar Icon up to 30 x 30 pts (transparent PNGs)
Text Field 31 pts
Height of a view inside a navigation bar 416 pts
Height of a view inside a tab bar 411 pts
Height of a view inside a navbar and a tab bar 367 pts
Portrait Keyboard height 216 pts
Landscape Keyboard height 140 pts


Points vs. Pixels

The iPhone 4 introduced a high resolution display with twice the pixels of previous iPhones. However you don't have to modify your  code to support high-res displays; the coordinate system goes by points rather than pixels, and the dimensions in points of the screen and all UI elements remain the same.
iOS 4 supports high resolution displays (like the iPhone 4 display) via the  scale property on UIScreen, UIView, UIImage, and CALayer classes. If the object is displaying high-res content, its scale property is set to 2.0. Otherwise it defaults to 1.0.
All you need to do to support high-res displays is to provide @2x versions of the images in your project. See the  checklist for updating to iOS4 or  Apple documentation for  Supporting High Resolution Screens for more info.

Adjusting Sizes

Click here to see how to adjust  View Frames and Bounds.

Additional References

  • Apple Documentation: Points vs. Pixels
  • Apple Documentation: UIBarButtonItem Class Reference says "Typically, the size of a toolbar and navigation bar image is 20 x 20 points."
  • Apple Documentation: UITabBarItem Class Reference says "The size of an tab bar image is typically 30 x 30 points."

7.iPhone之发送附件邮件代码

[cpp]  view plain copy
  1. MFMailComposeViewController *picker = [[MFMailComposeViewControlleralloc] init];
  2. picker.mailComposeDelegate = self;
  3. [pickersetSubject:@"I have a pencil for you"];
  4. NSString*databasePathFromApp = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"10.pdf"];
  5. NSData*fileData = [NSDatadataWithContentsOfFile:databasePathFromApp];
  6. [pickeraddAttachmentData:fileData mimeType:@"application/pdf"fileName:@"15.pdf"];
  7. [pickeraddAttachmentData:fileData mimeType:@"application/pdf"fileName:@"16.pdf"];
  8. UIImage*roboPic = [UIImage imageNamed:@"1.png"];
  9. NSData*imageData = UIImageJPEGRepresentation(roboPic, 1);
  10. [pickeraddAttachmentData:imageData mimeType:@"image/jpg"fileName:@"1.png"];
  11. NSString*emailBody = @"This is a cool image of a robot Ifound.  Check it out!";
  12. [pickersetMessageBody:emailBody isHTML:YES];
  13. [selfpresentModalViewController:picker animated:YES];
  14. [pickerrelease];

8.iphone之自动休眠定时器

Phone OS试图省电的一个方法是使用自动休眠定时器。

如果在一定的时间内没有检测到触摸事件,系统最初会使屏幕变暗,并最终完全关闭屏幕。大多数开发者都应该让这个定时器打开,但是,游戏和不使用触摸输入的应用程序开发者可以禁用这个定时器,使屏幕在应用程序运行时不会变暗。

将共享的 UIApplication对象的 idleTimerDisabled属性设置为 YES,就可以禁用自动休眠定时器。

9.iphone之广告转向

[cpp]  view plain copy
  1. NSString *iTunesLink =@"http://itunes.apple.com/us/app/id(产口id号)?mt=8";
  2. [[UIApplication sharedApplication] openURL:[NSURLURLWithString:iTunesLink]];

10.iphone之navigationItem 添加标题视图的方法

但是如果题目太长,后半部分就变成省略号了,那要实现自定义字体。代码如下:

[cpp]  view plain copy
  1. UILabel *titleText =[[UILabel alloc] initWithFrame: CGRectMake(0, 0,200, 20)];
  2. titleText.backgroundColor =[UIColor clearColor];
  3. [titleText setFont:[UIFontsystemFontOfSize:15.0]];
  4. [titleText setText:@"设置navigationItem标题的字体大小"];
  5. self.navigationItem.titleView=titleText;//titleView
  6. [titleText release];

11.iphone之开源类库工具

几个常用的开源类库及下载地址:

1. jsonjson编码解码
2. GTMBase64base64编码解码
3. TouchXMLxml解析
4. SFHFKeychainUtils安全保存用户密码到keychain中
5. MBProgressHUD很棒的一个加载等待特效框架
6. ASIHTTPRequesthttp等相关协议封装
7. EGORefreshTableHeaderView下拉刷新代码
8. AsyncImageView异步加载图片并缓存代码

iphone开发小技巧汇总相关推荐

  1. iphone开发小技巧汇总(1)

    1.iphone之xx_Prefix.pch的作用和用法    Prefix.pch:扩展名.pch表示"pre-compiled-header",这是一个你工程要用到的来自于外部 ...

  2. oracle ebs form 计算 汇总公式,Oracle+EBS+Form开发小技巧汇总

    oracle form开发的技巧 content Oracle EBS Form开发小技巧汇总 ..................................... 2 Form中Block的重 ...

  3. Android开发-小技巧汇总2

    启动虚拟机时,在 launch options 窗口中 有个 wipe user data ,勾选它,将会让虚拟机 [恢复出厂设置] 2.[如果想让自己的应用程序有多个启动图标:] 为一个应用的 多个 ...

  4. iOS开发小技巧汇总

    1.App名称的修改 许多个人开发者或许会有和我一样的经历,开发一个App途中会想到更合适的名字,这时候变会修改工程名以达到App名称改变的目的,其实你可以一步到位-- 在info.plist中添加一 ...

  5. iphone开发小技巧,转载

    1.获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量... 1.获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量: [(MyAppDelegate*)[[U ...

  6. VC小技巧汇总之对话框技巧

    这篇文章主要介绍了VC小技巧汇总之对话框技巧,非常实用!对于进行VC开发有一定的参考借鉴价值,需要的朋友可以参考下 本文搜集汇总了VC中关于对话框常用的一些技巧,对于进行VC开发由于一定的参考借鉴价值 ...

  7. 移动Web开发小技巧

    移动Web开发小技巧 添加到主屏后的标题(IOS) name="apple-mobile-web-app-title" content="标题"> 启用  ...

  8. 27个iOS开发小技巧

    <span style="word-wrap: normal; word-break: normal; line-height: 1.5em; font-size: 14px; out ...

  9. 日常安排php,PHP日常开发小技巧

    PHP日常开发小技巧 导语:PHP语言中,如果你懂得一些开发技巧,那么对你学PHP,会有很大的帮助.下面的是百分网小编为大家整理的PHP日常开发小技巧,希望对你能有所帮助. PHP批量取得checkb ...

最新文章

  1. python第一周小测验_Python小测试
  2. mysql concat键值对_MySQL中concat函数
  3. Jquery中怎样判断是否有网络
  4. Cocos2dx源码记录(11) CCPrimtiveCommand,CCPrimetive
  5. Python学习——02-Python基础——【9-面向对象进阶】——isinstance(obj,cls)、反射等...
  6. LeetCode 533. 孤独像素 II
  7. 电脑怎么卸载软件干净_不要说你的电脑卸载很干净!分享两款卸载神器!
  8. Linux下安装mongodb详细过程
  9. 安装引导黑屏_电脑黑屏要怎么重装系统修复
  10. 开发你自己的XMPP 续 - Openfire 插件开发
  11. java基于springboot+vue学生考勤签到请假管理系统84y43
  12. java udp发16进制数据_如何通过接口强制发送UDP数据包?
  13. 场景法设计测试用例ATM机取款问题
  14. English Grammar(二)
  15. 对自己狠一点,开始写作吧
  16. Amendment Quotation function in CLCL Plugin
  17. KPM算法思想及实现
  18. 世界上还有人以“厕所”为姓,都知道是哪国人
  19. python中使用什么命令安装组件_在离线环境下安装python组件
  20. iOS开发关于block和局部变量和全局变量

热门文章

  1. logback日志(requestId(请求ID))(processId(进程ID))
  2. 什麼是除甲醛?甲醛有害嗎?
  3. Linux如何将Mysql数据库自动从一台服务器备份到另一台服务器
  4. 微信小程序反编译wxss文件缺失_小程序反编译
  5. 【java笔记】java中用于小数进位的BigDecimal.setScale方法
  6. Java setScale方法保留n位小数
  7. LeetCode题解:704.二分查找
  8. java 无法读取文件_java 读取文件,无法显示文件内容,如何解决? 谢谢。
  9. vuex是什么?怎么使用?哪种功能场景使用它?
  10. 怎么把动图放到word里_WORD中如何插入动态图片