2011-09-30 42 views

回答

4
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{ 
    // iPad device 
} else { 
    // iPhone/iPod touch device 
} 

從Apple頭文件:

/* 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)