IPhone Development Study Notes 008-three methods to customize titles

Source: Internet
Author: User

Method 1:
Self. Title = @ "title text ";
Self. Title = [[[nsbundle mainbundle] infodictionary] objectforkey: @ "cfbundlename"];

Method 2:
Self. navigationitem. Title = @ "title text"

Method 3:
Self. navigationitem. titleview = xxxview;
Specifically, xxxview can be designed to be loaded through loadnibnamed: Owner: Options: or through code.

Pay special attention to the following two points:
(1) The premise for customizing the title is that the rootviewcontroller of the window applying delegate must be uinavigationcontroller. The uinavigationcontroller can use another uiviewcontroller as the parameter to be initialized through alloc and initwithrootviewcontroller.
For example:

Self. subviewcontroller =
[[[Subviewcontrolleralloc] init] autorelease];

Self. navigationcontroller
= [[Uinavigationcontrolleralloc] initwithrootviewcontroller: Self. subviewcontroller];

Self. Window. rootviewcontroller = self. navigationcontroller;

(2) The above three methods are set in uiviewcontroller, for example, in the-(void) viewdidload {} of subviewcontroller. After the third method is used, the first and second methods no longer work.

Instance: (figure)

Running effect:

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.