开发者

App that works on both IPad and IPhone

I was just wondering if there is a way to create an app in XCode that will detect whether it is being run on and IPhone or and IPad and select different views to suit the platform?

i.e. Pseudo Code

//IF CURRENT DEVICE IS IPHONE THEN
//SHOW IPHONE MAIN MENU VIEWCON开发者_Go百科TROLLER
//ELSEIF CURRENT DEVICE IS IPAD THEN
//SHOW IPAD MAIN MENU VIEWCONTROLLER

Thanks in advance


Yes it is called a "Universal App" and there is aTemplate for that project when you set a new "Window Based Application" in xcode.

to test if the device is ipad or iphone you can use this macro:

- (BOOL)isDeviceAniPad {
#ifdef UI_USER_INTERFACE_IDIOM
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
    return NO;
#endif
}

shani

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜