iOS let the back button show the custom title instead of the last Viewcontroller title

Source: Internet
Author: User

When developing iOS, it was found that when jumping from one viewcontroller to another viewcontroller, the return button of the Viewcontroller that was jumped to is always the title of the previous Viewcontroller. If the title of the last Viewcontroller more words will appear the interface is messy, so I want to achieve is the return button only show "back."

Development environment:

Ios:10

Xcode:8

Returns the display logic for a button

To know how to achieve the function you want first to grasp the relevant theoretical knowledge, the following examples illustrate.

If you jump from viewcontroller:a to B, then the display of the return button for B follows the following guidelines:
1. If a defines backbarbuttonitem, then B displays the backbarbuttonitem of a definition;
2. If b defines Leftbarbuttonitem, then B will display its own leftbarbuttonitem;
3. If a is undefined backbarbuttonitem,b also does not define Leftbarbuttonitem, then B displays the system default return button.

Implementing the Return button shows only "Back"

From the theory in the previous section, we can see that the principle of "1" can reach what I want to define Backbarbuttonitem in a:

Add the following statement to the Viewdidload method of a

"  Back ", Style:. Plain, Target:nil, action:nil);

iOS let the back button show the custom title instead of the last Viewcontroller title

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: info-contact@alibabacloud.com 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.