ios - How to perform different segue based on condition from a button click in swift? -


i'm building app in button takes profile registry view if open app first time , if open app other time. how can accomplish programmatically, have seen connects button 1 view.

@ibaction func nextviewcontroller(_ sender: uibutton) {     if launchedbefore  {         print("not first launch.")      } else {         print("first launch, setting userdefault.")           userdefaults.standard.set(true, forkey: "launchedbefore")     } } 

i think, trying connect button perform segue multiple viewcontroller right?? not possible

instead have connect segue between view controllers

adding segue between 2 viewcontrollers:

from interface builder, ctrl + drag between 2 viewcontrollers want link. should see:

enter image description here

and based on condition should perform segue identifiers below:

@ibaction func nextviewcontroller(_ sender: uibutton) {             if launchedbefore  {         /*use identifier given in story board*/                self.performsegue(withidentifier: "othervc", sender: self)              } else {     /*use identifier given in story board*/         self.performsegue(withidentifier: "register", sender: self))                 userdefaults.standard.set(true, forkey: "launchedbefore")             }         } 

for more descriptive answer segue see answer how connect 2 view controllers 1 button in storyboard?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -