WEB开发网
开发学院手机开发iPhone 开发 iPhone SDK 开发之 UIKit 使用 阅读

iPhone SDK 开发之 UIKit 使用

 2010-02-25 04:20:00 来源:WEB开发网   
核心提示:UIViewController会调用didReceiveMemoryWarning方法, 你可以在这个方法里释放自己的资源, 然后loadView会被重新自动调用.2.2 使用interface builder你可以用UIViewController类的initWithNibName方法加载interface bui
UIViewController会调用didReceiveMemoryWarning方法, 你可以在这个方法里释放自己的资源, 然后loadView会被重新自动调用.

2.2 使用interface builder

你可以用UIViewController类的initWithNibName方法加载interface builder创建的.xib资源文件.

MainViewController *myViewController = [

[ MainViewController alloc ]

initWithNibName: @"MainViewController"

bundle: nil

];

2.3 方向改变

(1)系统通过shouldAutorotateToInterfaceOrientation来检查是否可以旋转到interfaceOrientation所指示的方向.

-(BOOL)shouldAutorotateToInterfaceOrientation:

(UIInterfaceOrientation)interfaceOrientation

{

return (YES);

}

UIDeviceOrientationUnknown //Catchall for errors or hardware failures

UIDeviceOrientationPortrait //Oriented upright vertically in portrait mode

UIDeviceOrientationPortraitUpsideDown //Oriented upside-down vertically in portrait mode

UIDeviceOrientationLandscapeLeft //Device is rotated counter-clockwise in landscape mode

UIDeviceOrientationLandscapeRight //Device is rotated clockwise in landscape mode

UIDeviceOrientationFaceUp //Device is laying flat, face up, such as on a table

UIDeviceOrientationFaceDown //Device is laying flat, face down, such as on a table

(2)当方向改变时,系统会调用didRotateFromInterfaceOrientation

- (void)didRotateFromInterfaceOrientation:

(UIInterfaceOrientation)fromInterfaceOrientation

{

}

2.4 清除view controller

- (void)dealloc {

[ textView release ];

[ super dealloc ];

}

2.5 Controller demo

Example 3-7. ControllerDemo application delegate prototypes (ControllerDemoAppDelegate.h)

#import

@class ControllerDemoViewController;

上一页  1 2 3 4  下一页

Tags:iPhone SDK 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接