2010年10月8日 星期五

[iOS programing] 一些有用的小技巧整理 Some useful tips for your iOS applications

這裡收集在我的第一個程式中有用到的一些小技巧
Here are some useful tips I had used in my first APP. I collect all of them here.

1. 避免你的程式進入睡眠狀態
Prevent device entering sleep mode

Add this into your ${application name}AppDelegate.m
here is an example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.
application.idleTimerDisabled = YES;
MainMenuController *u_mainController = [[MainMenuController alloc] initWithNibName:@"MainMenuController" bundle:nil];
[window addSubview:u_mainController.view];
[window makeKeyAndVisible];
return YES;
}

2. 進入程式前的第一個畫面
The first image appears on the screen while loading application

這個相當簡單,只要把檔案加入你的專案中,然後將它的名字取為default.png就可以了,但有一件事要注意,如果用gif或jpeg在模擬器中是okay的,但實機上就會無法顯示:)
This is simple. Just add the image file into your project, and name it as "default.png". If you are using other image formats such as jpeg or gif. It still works in simulator. But it will show black screen in your iphone.


[.....to be continued]