Search code examples
iosios-universal-appadaptive-layout

Storyboard: assign IBOutlet for multiple object per size class


Since Apple introduce Size Classes, whew, routine work might gone, I thought. Going further, realised it's not so easy, so comfortable like it seemed to be.

My real purposes a bit different by I've set-up test project for illustration:

I have one storyboard, one IBOutlet for UIButton and decided this button to look different for different Size Classes

For that I created two buttons:

  • iPhone button (installed for wChC)
  • iPad button (installed for wRhR)

enter image description here

Problem:

each time when I try to connect any of those buttons to IBOutlet button - it always works for one button and erases connection to another.

enter image description here I want those two buttons to be actually one button but with different layout for iPhone, iPad. Previously, having two storyboards it haven't been an issue.

How to achieve this within one storyboard?


Solution

  • If you designed separately for iPhone/iPad means, you can't have same IBOutlet connection for both Button. Better to create separate IBOutlet for iPhone/iPad.

    Use Any|Any in storyboard for support both iPhone/iPad design with single IBOutlet.