我在正确显示导航视图的背景图像时遇到问题.这是图片:

这是代码:
- (id)initWithStyle:(UITableViewStyle)style {
if (self = [super initWithStyle:style]) {
UIImage *image = [UIImage imageNamed: @"bg_table_active.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithTitle:NSLocalizedString(@"Settings", @"")
style:UIBarButtonItemStyleDone
target:self
action:@selector(GoToSettings)];
self.navigationItem.titleView = imageview;
self.navigationItem.rightBarButtonItem = addButton;
self.navigationItem.hidesBackButton = TRUE;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
如何将图片拉伸到整个导航视图?
我在xib中添加了导航栏和导航项.现在我需要在导航栏的左侧添加图像,但它没有被添加.这是我正在处理的代码:
- (void)viewDidLoad
{
UIImage *image = [UIImage imageNamed: @"i_launcher.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;
[imageView release];
}
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么图像没有被添加.我该如何添加它?