Iphone 如何在导航栏的按钮上设置图像?
我需要把图像的添加,取消和返回按钮的导航栏。我已经完成了添加按钮,但没有得到返回按钮 即使使用此添加按钮图像,它也会显示蓝色自定义按钮。如何设置此按钮Iphone 如何在导航栏的按钮上设置图像?,iphone,xcode,cocoa-touch,uibarbuttonitem,Iphone,Xcode,Cocoa Touch,Uibarbuttonitem,我需要把图像的添加,取消和返回按钮的导航栏。我已经完成了添加按钮,但没有得到返回按钮 即使使用此添加按钮图像,它也会显示蓝色自定义按钮。如何设置此按钮 UIBarButtonItem *addButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bar_add_button.png"] style:UIBarButtonSystemItemAdd target:self
UIBarButtonItem *addButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bar_add_button.png"]
style:UIBarButtonSystemItemAdd target:self
action:@selector(addNote)];
您正在向我们显示
addButton
code。这是我在添加按钮上放置图像的方式。尝试后退按钮和取消按钮您正在向我们显示addButton
代码。这是我在添加按钮上放置图像的方式。尝试后退按钮和取消按钮初始化该接口类型的UIBarButton时出错无法静态分配*在开始时剩余bBarButtonItem@HeenaDave我的错误请参见更新的代码。uibarbuttonite是一个对象,我忘了在上面加一个*@Heena Dave。你是iPhone开发新手吗?是的,我是iPhone开发新手。这就是为什么我的问题太核心的原因。!!初始化UIBarButtonim时出错,无法静态分配接口类型*仍保留在bBarButtonItem@HeenaDave我的错误请参见更新的代码。uibarbuttonite是一个对象,我忘了在上面加一个*@Heena Dave。你是iPhone开发新手吗?是的,我是iPhone开发新手。这就是为什么我的问题太核心的原因。!!
// Initialize the UIButton
UIImage *buttonImage = [UIImage imageNamed:@"buttonImage.png"];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setImage:buttonImage forState:UIControlStateNormal];
aButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
// Initialize the UIBarButtonItem
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];
// Set the Target and Action for aButton
[aButton addTarget:self action:@selector(aButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
// Then you can add the aBarButtonItem to the UINavigationBar
...
self.navigationItem.leftBarButtonItem = aBarButtonItem;
// Release buttonImage
[buttonImage release];