Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.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 iOS 4.0中未显示uibarbuttonite_Iphone_Uibarbuttonitem - Fatal编程技术网

Iphone iOS 4.0中未显示uibarbuttonite

Iphone iOS 4.0中未显示uibarbuttonite,iphone,uibarbuttonitem,Iphone,Uibarbuttonitem,在iOS 5.0中一切正常,但当我在iOS 4.0中运行代码时,导航栏按钮的背景图像以及导航栏中的标题都不会显示 以下是我正在使用的代码: // check for version 5.0 support navController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease]; UINavigationBar *navigationBar = [n

在iOS 5.0中一切正常,但当我在iOS 4.0中运行代码时,导航栏按钮的背景图像以及导航栏中的标题都不会显示

以下是我正在使用的代码:

// check for version 5.0 support
navController  = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
UINavigationBar *navigationBar = [navController navigationBar];
if ([navController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
    UIImage *image = [UIImage imageNamed:@"Nav_Bar.png"];
    [navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}

else
{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"Nav_Bar.png"]];
    [self.navController.navigationBar addSubview:imageView];
}
然后在
viewDidLoad
中:

self.title = @"MyTitle";

self.leftBTN=  [UIButton buttonWithType:UIButtonTypeCustom];
[leftBTN setImage:[UIImage imageNamed:@"BTN1.png"] forState:UIControlStateNormal];
[leftBTN setTitle:@"Edit" forState:UIControlStateNormal];
[leftBTN addTarget:self action:@selector(editOption) forControlEvents:UIControlEventTouchUpInside];
[leftBTN setFrame:CGRectMake(0, 0, 60, 30)];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:leftBTN] autorelease];
请任何人解释一下,为什么导航控制器中没有显示图像和标题。
而且,如果我点击那个框架,按钮的动作是正常的,唯一的问题是按钮没有显示。

这是iOS 4的问题。将视图添加到导航栏时,子视图处理不正确。它在iOS 5中解决

看这个


它有一个示例项目,在iOS 4和iOS 5的导航栏中都有背景图像。这是iOS 4的一个问题。将视图添加到导航栏时,子视图处理不正确。它在iOS 5中解决

看这个


它有一个示例项目,在iOS 4和iOS 5的导航栏中都有背景图像。

不,不是那样的。不,不是那样的。