How to popup and dismiss the viewcontrollers from root view controller in iphone
<p>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 directly.</p>

<p>I am doing [self popToRootViewController] and [2nd viewcontroller dismissModalViewControllerAnimated:NO];</p>

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

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

<p>thanks in advance.</p>
