ios - Is it possible for a button to open into a specific tab when using the Tab Bar Controller? -


the question little confusing articulate image little more helpful. here's setup:

enter image description here

so, want first view button open firstviewcontroller, , want second view button open secondviewcontroller. if link second view button secondviewcontroller this:

enter image description here

i lose tab navigation. , if connect button tabviewcontroller this:

enter image description here

then automatically open firstviewcontroller. unless i'm missing something, seems need done little code cannot seem find explains how this.

thank you!

create storyboard segue viewcontroller tabbarcontroller identifier. assign selelctedindex value of tabbarcontroller in prepareforsegue method

storyboard

@ibaction func firstbtnaction(_ sender: any) {     (sender as! uibutton).tag = 0     performsegue(withidentifier: "tabbar", sender: sender) } @ibaction func secbtnaction(_ sender: any) {     (sender as! uibutton).tag = 1     performsegue(withidentifier: "tabbar", sender: sender) }  override func prepare(for segue: uistoryboardsegue, sender: any?) {     if segue.identifier == "tabbar" {         if let vc = segue.destination as? uitabbarcontroller {             vc.selectedindex = (sender as! uibutton).tag         }     } } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -