1

我知道可以将 iPad 应用程序转换为通用应用程序,我的问题是是否值得。

该应用程序所做的只是显示一个初始屏幕,其中包含使用 UDP 广播检测到的服务器列表。一旦用户单击一个,它就会从该服务器加载一个页面到 UIWebViewControl。就是这样。这很简单。我已经研究过将现有的 iPad 应用程序转换为通用应用程序,但我不太喜欢这个过程。我的主要问题是在没有故事板便利的情况下理解界面构建器,尤其是原始编码器设置它的方式。我也不确定如何让应用程序为 iPhone / iPod 加载与 iPad 不同的视图。

话虽如此,我应该转换应用程序还是重新编写它?

4

2 回答 2

2

您的通用转换应该毫不费力。您的 iPad 用户会欣赏这项工作。但除非您计划添加一些重大的 UI 更改,否则一定要转换它,在这些更改中重写将是有益的。

在从 iPhone 代码中确定 iPad 代码的简单方法中,使用:

#define IDIOM    UI_USER_INTERFACE_IDIOM()
#define IPAD     UIUserInterfaceIdiomPad
#define IPHONE   UIUserInterfaceIdiomPhone

关于上述IDIOM内容,我看到 Apple 在 iOS 5.1 中使用了以下内容:

[[UIDevice currentDevice] userInterfaceIdiom]

所以你也可以使用

#define IDIOM    [[UIDevice currentDevice] userInterfaceIdiom]

例子

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ( IDIOM == IPAD ) {
        /*  Device is an iPad, so let the interface rotate.  */
        return YES;
    }else{
        /*  Device is an iPhone / iPod touch, so do not allow the interface rotate.  */
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    return YES;
}
于 2012-03-20T21:56:06.373 回答
1

如果应用程序那么小,请从头开始。如果您认为值得这样做,您可以复制大部分旧代码。

于 2012-03-20T21:53:15.207 回答