The difference between present and push

Source: Internet
Author: User

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,

      1. In the Viewdidload:
      2. [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (back) name:@ "Backback" object:nil];
      3. -(void) back
      4. {
      5. [Self dismissmodalviewcontrolleranimated:yes];
      6. }

The difference between present and push

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.