简体   繁体   English

通用ios app iPad和iPhone架构

[英]universal ios app iPad and iPhone architecture

I'm creating a universal iOS app. 我正在创建一个通用的iOS应用。 I have a different UI for each one of them in most of the screens. 在大多数屏幕上,我每个人都有一个不同的UI。 There are about 15 screens. 大约有15个屏幕。 I'm coming from Android and trying to find the best solution for that. 我来自Android,并试图为此找到最佳解决方案。

  1. on the iPhone i use portrait mode. 在iPhone上,我使用人像模式。
  2. on the iPad i use landscape mode. 在iPad上,我使用横向模式。
  3. I use Constraints / Auto layout. 我使用约束/自动布局。
  4. Some of the views have nibs, some in code. 一些视图有笔尖,一些在代码中。
  5. because of that, the logic is a bit different in each one. 因此,两者的逻辑有些不同。
  6. iPad have 2 menus you can swipe from top to bottom and left to right. iPad有2个菜单,您可以从上到下以及从左到右滑动。
  7. iPhone has no draggable menus. iPhone没有可拖动的菜单。
  8. both use same Api calls to the server. 两者都使用对服务器的相同Api调用。

I looked a bit on stack overflow, and got some of those methods: 我看了一下堆栈溢出,得到了其中一些方法:

Should I use 2 different classes, and 2 nibs? 我应该使用2个不同的类和2个笔尖吗? Or maybe 1 class with tons of if else? 或者也许是一类,如果还有吨呢? Use different targets? 使用不同的目标?

Is one of those is the best way? 这些是最好的方法之一吗? Is there any other way? 还有其他办法吗?

different targets 不同的目标

same class with if/else 与if / else同班

IPAD:: IPAD :: iPad的

IPHONE:: 苹果手机:: 在此处输入图片说明

When I need to design a universal app I look at the interface I think I need to support and try: 当我需要设计通用应用程序时,我看一下我需要支持并尝试的界面:

  1. Can the different layouts be handled by autolayout constraints? 自动布局约束可以处理不同的布局吗? If so great, I only need one view. 如果这么好,我只需要一个视图。
  2. If the views are significantly different can I define a common IBOutlet/Action interface to a view controller? 如果视图明显不同,我可以为视图控制器定义一个公共的IBOutlet / Action接口吗? If so I can use one view controller (which is not full of conditional branches) to support views defined in multiple nibs. 如果是这样,我可以使用一个视图控制器(不包含条件分支)来支持多个笔尖中定义的视图。
  3. If the view structure is radically different or the presented view controllers vary greatly (split view controllers for example) then I probably need multiple view controllers, each with their own views/nibs but those controllers should be as thin as possible and share a common set of models, data sources, networking services, and other business logic. 如果视图结构完全不同,或者显示的视图控制器相差很大(例如,拆分视图控制器),那么我可能需要多个视图控制器,每个视图控制器都有自己的视图/笔尖,但是这些控制器应该尽可能地薄,并共享一个公共集合模型,数据源,网络服务和其他业务逻辑的集合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM