1.Use Uinavigationcontroller to return to the previous view using the pushviewcontroller:animated----[[Self navigationcontroller] Popviewcontrolleranimated:yes];---ps:push will automatically add the Back button in navigation's left bar, and it responds by returning. So generally do not need to write the return method, click the Back button.
2.Other times with presentmodalviewcontroller:animated [self Presentmodalviewcontroller:controller animated:yes];// Yes animated-----Return to previous view [self dismissmodalviewcontrolleranimated:yes];
3.Switching views generally do not use Addsubviewuinavigationcontroller is the navigation controller, if Pushviewcontroller, will jump to the next Viewcontroller, Point back will return to the present Viewcontroller, if it is addsubview, in fact, or the current viewcontroller operation, but in the current view and "cover" a layer of view, in fact, the original picture in the following, do not see it. (Of course, you can also use Insertsubview Atindex that method to set the level of placement). Plus a
Using the Presentmodalviewcontrolleranimated method from A->b->c, if you want to return a in C directly, you can do this:
Return event in C:
- void back
- {
- [Self dismissmodalviewcontrolleranimated:no];//note must be no!!
- [[Nsnotificationcenter defaultcenter]postnotificationname:@ "Backback" object:nil];
- }
And then in B,
- In the Viewdidload:
- [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (back) name:@ "Backback" object:nil];
- -(void) back
- {
- [Self dismissmodalviewcontrolleranimated:yes];
- }
The difference between present and push