How to create UINavigationItem.TitleView based on nib file?

I have a UINavigationController, a bass sequence of screens. On one of the screens, I want to replace the standard title with a custom TitleView. A custom view will be created using the nib file and will have an image and several labels.

Create a UIViewController file with the associated nib file, load nib, and assign the .view TitleView property? Basically, how can I use a thread where I can place the necessary elements and then assign the resulting view to the TitleView property?

+1
source share
2 answers

UINib - iOS 4.0. , .

UINib *nib = [UINib nibWithNibName:@"TestView" bundle:nil];
UIView *myView = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0]];

AtIndex NIB - ( 0), , .

, navigationItem titleView

self.navigationItem.titleView = myView;
[myview release];

EDIT:

NIB, viewWithTag. . :

http://useyourloaf.com/blog/2011/2/28/speeding-up-table-view-cell-loading-with-uinib.html

+1

Interface Builder ( IBOutlet iVar, ). titleView .

UIView * customTitleView = [[[NSBundle mainBundle] loadNibNamed:@"TitleView" owner:self options:nil] lastObject];
self.navigationItem.titleView = customTitleView;
[customTitleView release];
0

All Articles