Do we need to use 2 Storyboard for a Universal app?

前端 未结 6 1796
星月不相逢
星月不相逢 2021-02-06 12:01

I have a project for iPhone and iPad. The iPad needs a split view controller. Do we create two separate storyboards? One for iPhone (using autolayout we can support all devices)

6条回答
  •  無奈伤痛
    2021-02-06 12:42

    I managed to have that scenario (split controller in an universal storyboard that works on both iOS8 and iOS7) by calling a different segue while on iOS7 and iPhone. My scenario is like this:

    I have a login controller that is supposed to segue to a main controller (modally).

    When on iOS8 or iPad I use a segue points to the split view controller, while when on iOS7-iPhone I use another segue that points directly to the left nav controller of the split controller (bypassing it entirely).

    If from the left controller you have a detail segue that points to the right nav controller(and you should) and if the segue type is "Show Detail" (and it should) then it will perform like a regular push in the iOS7-iPhone environment (which is exactly what we want).

    On thing I noticed though, the detail segue's destination controller in the IOS7-iPhone scenario becomes the root view controller of the right nav (even though the segue is pointing to the nav), therefore, if you have some code in the prepareForSegue you might need to adapt it to handle them differently)

    (For determining if the platform is IOS8 and if I'm on iPhone/iPad idiom I use the standard

    [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 and UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    

提交回复
热议问题