适用于 iPhone 和 iPad 的通用应用程序概念
我是通用应用程序的菜鸟,所以请帮助我,让我知道这是否可以完成,我正在创建一个通用应用程序,为此我已经编写了代码并在 iPhone 中的每个视图控制器中进行了设置和 iPad 组,在运行时我正在识别设备,无论是 iphone 还是 ipad,我正在使用下面的方法
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { myiPad_View *ipadObj = [[myiPad_View alloc]init]; [self.window addSubview:ipadObj.view]; } else { myiPhoneView *obj = [[myiPhoneView alloc]init]; [self.window addSubview:obj.view]; }
现在问题是我的老板为此而烦恼,他告诉我我们可以只写一个类并在运行时该应用程序将在 iPhone 或 iPad 设备或模拟器中启动,视图控制器将相应地调整帧我已经使用上述方法完成了这一点,但他说如果你这样做,那么代码将会增加,你必须遭受巨大的损失头痛,所以实际上他是对的,但还没有找到任何替代解决方案,所以在说这不能完成之前,我想听取一些专家的建议
am a noob at universal apps so please help me out and let me know if this can be done, I am creating a universal app and for doing this i have written the code and made the settings in each of my view controllers present in the iPhone and iPad group and at runtime i am identifying the device whether its iphone or ipad i am using the below method
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { myiPad_View *ipadObj = [[myiPad_View alloc]init]; [self.window addSubview:ipadObj.view]; } else { myiPhoneView *obj = [[myiPhoneView alloc]init]; [self.window addSubview:obj.view]; }
Now the query is my boss is eating my head for this he is telling me that can we write just one class and at run time when the app will be launched either in iphone or ipad device or simulator the view controller will adjust the frames accordingly i have done this by using the above method but he says if you do like this then the code will increase and you have to suffer a huge headache so actually he is right but haven't found of any alternate solution to this, so before saying this cant be done i thought of taking some expert advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的上述方法实际上也是我在某些应用程序中确定设备的方法。
事实上,我最近写了一篇关于这个问题的小文章。
您还可以使用:
或
Your above method is actually how I determine devices in some of my apps as well.
I actually recently wrote a little piece on this issue.
You can also use:
or
我有 3 组类:
我在基类中拥有尽可能多的内容,但是对于逻辑分离的时代,拥有不同的类要容易得多。在我看来,挖掘代码寻找异常会很痛苦。
我发现此博客很有帮助(不是我的)
I have 3 sets of classes:
I have as much as possible in the base classes, but for the times when the logic is separate, it is much easier to have the distinct classes. Digging through the code looking for the exceptions would be a pain, IMO.
I found this blog helpful (not mine)
这不是问题。你必须创建一个通用应用程序。
,然后选择一个产品
Universal
。Its not a problem . you have to create a universal app.
and then choose a product
Universal
.