sitara sitara - 1 year ago 91
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download