iphone開發備忘

安迪潘發表於2011-10-25
1. 新增sqlite框架的路徑如下: 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/libsqlite3.dylib 

2. iPhone開發不使用xib檔案的方法: 

修改main.m裡的UIApplicationMain引數為 

UIApplicationMain(argc, argv, nil, @"AppDelegate");
// AppDelegate為你的ApplicationDelegate
AppDelegate:

UIWindow *localWindow = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
localWindow.backgroundColor = [UIColor whiteColor];
self.window = localWindow;
[localWindow release];

navigationController = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];

3. SQLITE建表語句 

CREATE TABLE accountbook(id integer primary key autoincrement,
price number,
costtime date,
categorycode varchar(2),
categoryname varchar(20),
year varchar(4),
month varchar(2),
day varchar(2));

4. linux/MAC下強制結束程式 
ps -ef   //檢視程式號 
kill -9 程式號    //強制結束 

5. iphone程式設定啟動橫屏 
只要在Info.plist裡面加UIInterfaceOrientation 
給個 UIInterfaceOrientationLandscapeRight 就可以了 

6. 彩色UIProgressView 

http://pwiddershoven.nl/blog/2009/01/04/colored-uiprogressview.html 

7. Cover Flow Effect 
http://blog.objectgraph.com/index.php/2010/04/09/how-to-add-coverflow-effect-on-your-iphone-app-openflow/ 

8. 設定uitableview backgroundcolor: 
正常情況下: 
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundPattern.png"]]; 

grouped tableview: 
[tableView setBackgroundView: nil]; 
[tableView setBackgroundView: [[[UIView alloc] init] autorelease]]; 
[tableView setBackgroundColor: UIColor.clearColor]; 
//設定底色為無色 

9 工具欄居中 

//新增底部拍照的工具欄
    
    //左空格
    
    UIBarButtonItem *leftflexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    
    //右空格
    
    UIBarButtonItem *rightflexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    
    UIBarButtonItem *cameraitem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action: @selector(beginScan)] autorelease];   
	NSArray *myToolbarItems = [[NSArray alloc] initWithObjects: leftflexible,cameraitem,rightflexible, nil];                   
	[self setToolbarItems: myToolbarItems animated:YES];


相關文章