sitara sitara - 2 months ago 11x
Swift Question

How to set action for a button when using different storyboard for iphone and ipad?

I want to use different storyboards for ipad and iphone. I successfully did it by following this tutorial.

But I want to know how to call the same action for the

in both iPad and iPhone.


Create one IBAction and assign it the button in your storyboards, Now if you want to differentiate is it call from iphone or ipad you can add condition for that in your IBAction.

@IBAction func buttonClick(sender: UIButton) {
    if (UIDevice.currentDevice().userInterfaceIdiom == .Pad) {
         // It is from iPad
    else { 
         // It is from iPhone