开发者

Jumping back and displaying a VC more that 2 layers underneath the top VC

I have the base ViewController which i my main menu(VC1). From there I navigate to another VC which displays a UITable(VC2). From here i can call [self.parentViewController dismissModalViewControllerAnimated:YES]; To move back to the main menu. That works fine. If i load another VC(V3) with displays a UIWebView from VC2 and want to jump back to the main menu(VC1), how can this be done in the best way?

So I navigate VC1->VC2->VC3 and then want to jump VC3->VC1.

My app doesn't have a UINav开发者_如何学GoigationViewController or anything like that.

Many Thanks, -Code


You could try creating a method in the parent vc (vc2) that you call from vc3 that does the following:

-(void)dismissTwo
{
  [self dismissModalViewControllerAnimated:NO];
  [self.parentViewController dismissModalViewControllerAnimated:YES];
}

That's untested, but give it a shot.


Its tricky if you used navigation controller you could have popped to root view controller using poptorootviewcontroller.

However in your case if you can implement a delegates for VC2 and VC3. In the delegate for VC3 in VC2 dismiss VC3 and call delegate of VC2 which is implemented in VC1.

So basically the flow is as follows

  1. Create VC1
  2. When you create VC2 from VC1 assign delegate to VC1
  3. When you create VC3 from VC2 assign delegate to VC2

From this point on you can pass messages in a cleaner way between the view controllers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜