我想區分iPhone和iPad的控制器。如何在通用應用程序中區分iPhone和iPad?
#ifdef __IPHONE_NA
{
UINavigationBar *ipadNavBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 768.0f, 50.0f)];
[[self view] addSubview: ipadNavBar];
UINavigationItem *ipadNavItem = [[UINavigationItem alloc] initWithTitle: @"EMPLOYEE"];
[ipadNavBar pushNavigationItem:ipadNavItem animated:NO];
}
else
{
UINavigationBar *ipadNavBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 360.0f, 45.0f)];
[[self view] addSubview: ipadNavBar];
UINavigationItem *ipadNavItem = [[UINavigationItem alloc] initWithTitle: @"EMPLOYEE"];
[ipadNavBar pushNavigationItem:ipadNavItem animated:NO];
}
如果說錯誤未終止的#ifdef
是這種做法是否正確?
thanks Crazy Chimp! – user905582 2012-01-07 23:54:02
沒問題 - 很高興我能幫上忙! – 2012-01-08 11:21:38
應用程序需要通用才能執行iPad程序塊。 – 2014-11-14 00:08:10