以下是library中所註明的資訊,可在xcode中對使用的關鍵字userInterfaceIdiom按下command+滑鼠左鍵去檢視
typedef enum {
#if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIUserInterfaceIdiomPhone, // iPhone and iPod touch style UI
UIUserInterfaceIdiomPad, // iPad style UI
#endif
} UIUserInterfaceIdiom;
/* The UI_USER_INTERFACE_IDIOM() macro is provided for use when deploying to a version of the iOS less than 3.2. If the earliest version of iPhone/iOS that you will be deploying for is 3.2 or greater, you may use -[UIDevice userInterfaceIdiom] directly.
*/
#define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)
<以下使用範例>
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone) { UIViewController* IPhoneViewController1=[[UIViewController alloc]init]; self.window.rootViewController= IPhoneViewController1; } else if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad) { UIViewController* IPadViewController1=[[UIViewController alloc]init]; self.window.rootViewController= IPadViewController1; }
or if you have nib file, you can type
[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
As always, if you have any question , feel free to contact me.
有任何問題,請聯絡我
沒有留言:
張貼留言