开发者

How to popup and dismiss the viewcontrollers from root view controller in iphone

I have a MainViewController and i am Presenting another viewcontroller(2nd ViewController) through [self PresentModalViewControllerAnimated:YES]; And this modalViewController is a NavigationController from this i am pushing to DetailViewController. Now in DetailViewController if i click on a button i should go to MainViewController 开发者_C百科directly.

I am doing [self popToRootViewController] and [2nd viewcontroller dismissModalViewControllerAnimated:NO];

but i am not getting, the above code taking me to 2nd view controller not to the mainviewcontroller.

any one have any idea about how we can do this.please share your ideas or sample code to achieve this.

thanks in advance.


You can use NSNotification. In your detailview controller when the button is pressed, you can post a notification. In the mainViewController you can keep a notification observer. Then upon receiving notification, you can fire a method to dissmiss the modalviewcontroller.

I hope this will help you.


I am not clear what you are really trying to ask.

But still, if I am guessing right, try calling [mainViewController dismissModalViewControllerAnimated:NO];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜