Note that there are some explanatory texts on larger screens.

plurals
  1. POShould we avoid push segue loop between two view?
    primarykey
    data
    text
    <p>Well, to some of you this question may sounds ridiculous but I'm discussing with my teammates about the design of an ios app and I need your opinion about it. </p> <p>The old design which I disagree is as following</p> <ul> <li>We have ViewControllerA which contains Button "Go To B". The button has a PUSH segue to go to B. </li> <li>We have ViewControllerB which contains Button "Go To A".The button has a PUSH segue to go to A.</li> <li>We have to travel between the 2 ViewController a lot.</li> </ul> <p>As you can see, there is a segue loop between ViewController A and B and I think we should never let it happens. I would prefer go from B to A by "Back" button in navigation bar.</p> <p>How serious is the PUSH segue loop in design? Is it acceptable in some cases? Where can I see the recommended good design by apple (if there are any?)</p> <p><strong>EDIT:</strong> I try "pop before push" solution by nfarshchi but it do not work.This is how I did: 1) I cannot create segue from VC A to VC B and segue from VC B to VC A at the same time. It seems that storyboard prevents it from happening 2) Thus I create one segue whose identifier is "gotoB" from Button "Go to B" in VC A to VC B and one segue whose identifier is "gotoA" from Button "Go to A" in VC B to VC A.</p> <p>So the Storyboard would looks like this: </p> <p>VC X ---Push---> VC A &lt;----Push----> VC B (The reason I need ViewController X is explained later) 3) In VC A I have this:</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSLog(@"Prepage for segue go to B") ; if ([[segue identifier] isEqualToString:@"gotoB"] ) { [self.navigationController popViewControllerAnimated:NO]; } } </code></pre> <p>I need VC X because I cannot pop a ViewController from Stack if there is only one ViewController in there.</p> <p>Now it seems right, but when I clicked "Go to B", it went to VC X instead. It was clearly that the above popViewControllerAnimated: has poped VC A, and that's all, the segue to VC B was no longer fired. The result was the VC B was not pushed into Stack as expected.</p> <p>Thus I think it is unfeasible to implement nfarshchi's solution</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload