ios - popToRootViewController not working when sending from add screen -


i have simple app building. list of items in 1 view controller table view , embedded navigation controller. when select row brings details screen (no problem).

push list view list item

func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) {     performsegue(withidentifier: "listitemdetailsvc", sender: nil) } 

pop list item list view

@ibaction func backtoinboxtapped(_ sender: any) {     navigationcontroller?.poptorootviewcontroller(animated: true) } 

this works fine!

my issue have view controller (add item) presents modally when add button clicked. idea when saves brings list detail vc.

@ibaction func saveitem(_ sender: any) {     performsegue(withidentifier: "detailsfromadd", sender: nil) } 

opening details view controller add new controller works fine once open details view want able go rootviewcontroller. button not work anymore

enter image description here

in case should not need use segue. have clear concepts.

you can't poptorootviewcontroller or vc if have pushed or show view controller modally presented vc!!

now if want achieve have make changes trying mention below :

take 1 global variable or property (objective c concept) in add item vc. when come add item vc lust vc set global variable or property self like,

   addlistitemvc *advc = [self.storyboard instantiateviewcontrollerwithidentifier:@"addlistitem"];  // addlistitem storyboard id viewcontroller     [self presentviewcontroller:advc animated:no completion:^{       advc.vc = self;  // here vc propery of type `uiviewcontroller` declare in addlistitemvc  }]; 

now code going details vc add list vc should like,

    detaillistviewcontroller *dvc = [self.storyboard instantiateviewcontrollerwithidentifier:@"detailviewscreen"];   // detailviewscreen storyboard id can set identity inspector    [self dismissviewcontrolleranimated:no completion:^{       [self.vc.navigationcontroller pushviewcontroller:dvc animated:yes];  // here self.vc global variable or property contains reference of first vc (i.e. list view controller)   }]; 

no need use performsegue in case. can use performsegue go in detailvc directly firstvc mean list vc.

hope got understand concept , have written objective c snippet because of lake of time!! hope can convert swift!!


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -