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?
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
Interface Builder ( IBOutlet iVar, ). titleView .
titleView
UIView * customTitleView = [[[NSBundle mainBundle] loadNibNamed:@"TitleView" owner:self options:nil] lastObject]; self.navigationItem.titleView = customTitleView; [customTitleView release];