作为我的头衔,我浏览了几个网站,但未能取得成效。不过,我成功地在导航栏上添加了一个图像。这是我目前面临的两个问题,都在UINavigationBar部分。 1.无法显示rightbarbutton 2.无法隐藏后退箭头 “<”UINavigationItem rightbarbuttonitem not displayed
MasterViewController.m
//Back Button
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backBtnImage = [UIImage imageNamed:@"sidemenu.png"];
[backBtn setBackgroundImage:backBtnImage forState:UIControlStateNormal];
backBtn.frame = CGRectMake(0, 0, 54, 30);
//Rightbarbutton
UIButton *infoButton = (UIButton *) [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_info.png"]];
UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
self.navigationItem.rightBarButtonItem = infoButtonItem;
//Image (Working and displaying)
UIImage *image = [UIImage imageNamed: @"icon_image.png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(245, 0, 30, 42)];
[imageView setImage:image];
[self.navigationController.navigationBar addSubview:imageView];
相同的程序是bringSubviewToFront?正如我刚刚“没有可见@interface for'UINavigationBar'声明选择器'bringSubviewToBack:”。 – aka
对不起,我编辑了答案,这是sendSubviewToBack –
它不工作... – aka