universal ios app iPad and iPhone architecture

I'm creating a universal iOS app. I have a different UI for each one of them in most of the screens. There are about 15 screens. I'm coming from Android and trying to find the best solution for that.

  • on the iPhone i use portrait mode.
  • on the iPad i use landscape mode.
  • I use Constraints / Auto layout.
  • Some of the views have nibs, some in code.
  • because of that, the logic is a bit different in each one.
  • iPad have 2 menus you can swipe from top to bottom and left to right.
  • iPhone has no draggable menus.
  • both use same Api calls to the server.
  • I looked a bit on stack overflow, and got some of those methods:

    Should I use 2 different classes, and 2 nibs? 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

    IPAD:: iPad的

    IPHONE:: 在这里输入图像描述


    When I need to design a universal app I look at the interface I think I need to support and try:

  • Can the different layouts be handled by autolayout constraints? If so great, I only need one view.
  • If the views are significantly different can I define a common IBOutlet/Action interface to a view controller? If so I can use one view controller (which is not full of conditional branches) to support views defined in multiple nibs.
  • 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.
  • 链接地址: http://www.djcxy.com/p/95786.html

    上一篇: 通用iPhone和iPad应用程序

    下一篇: 通用ios应用程序iPad和iPhone架构