Method 1:
Self. Title = @ "title text ";
Or
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: