Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 导航栏图像隐藏自定义导航栏按钮_Iphone_Ios_Uinavigationitem_Navigationcontroller - Fatal编程技术网

Iphone 导航栏图像隐藏自定义导航栏按钮

Iphone 导航栏图像隐藏自定义导航栏按钮,iphone,ios,uinavigationitem,navigationcontroller,Iphone,Ios,Uinavigationitem,Navigationcontroller,我能够给导航栏的图像,也改变了导航栏按钮项目的图像。出于某种原因,我猜导航栏的图像和导航栏按钮的图像重叠了。当我点击左边的导航栏图像时,导航栏按钮在右边工作,但它并没有显示在导航栏图像上。这是代码 UIImage *imagebar = [UIImage imageNamed: @"schedule-strip.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage: imagebar]; imageView.fram

我能够给导航栏的图像,也改变了导航栏按钮项目的图像。出于某种原因,我猜导航栏的图像和导航栏按钮的图像重叠了。当我点击左边的导航栏图像时,导航栏按钮在右边工作,但它并没有显示在导航栏图像上。这是代码

UIImage *imagebar = [UIImage imageNamed: @"schedule-strip.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: imagebar];
imageView.frame = CGRectMake(0, 0, 190, 44);
imageView.contentMode = UIViewContentModeScaleAspectFill;
self.navigationItem.titleView = imageView;


UIImage* image = [UIImage imageNamed:@"back-icon.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* someButton = [[UIButton alloc] initWithFrame:frame];
[someButton setBackgroundImage:image forState:UIControlStateNormal];
[someButton setShowsTouchWhenHighlighted:YES];
[someButton addTarget:self action:@selector(backToMore) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* someBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:someButton];
[self.navigationItem setLeftBarButtonItem:someBarButtonItem];

[someBarButtonItem release];
[someButton release]; 

帮帮我。

科坦:你检查图像了吗?您的项目中是否存在图像? 为什么要对导航栏标题使用框架和内容模式属性? 这个链接可以帮助你吗

扩展@interface MyToolBar:UIToolbar并使其成为MyToolBar的对象。之后,为导航栏创建自定义按钮。享受并喜欢它

使用代码 [imageView addsubView someButton]


我希望现在你能看到这个按钮。实际上,你正在将左栏按钮项添加到默认的导航栏中,当你创建某个按钮时,它不会添加到与导航栏重叠的imageview上。因此,通过单击该区域,它可以工作,但按钮不可见。

你提到的项目中使用的图像是只有一个垂直条带(一条线),我有完整的图像提供给导航栏,但唯一的问题是导航栏按钮没有显示;
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"TopBg.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}