我创建了一个自定义按钮并将其应用于 UIbarbuttonitem。
没有错误,但导航栏上没有显示任何内容:(
这是我的代码-
//create a custom button
UIImage *image = [UIImage imageNamed:@"TESTButton.png"];
UIButton *myCustomButton = [UIButton buttonWithType:UIButtonTypeCustom];
myCustomButton.bounds = CGRectMake( 0, 0, image.size.width, image.size.height );
[myCustomButton setImage:image forState:UIControlStateNormal];
[myCustomButton addTarget:nil action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:myCustomButton];
self.navigationItem.leftBarButtonItem = button;
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
[button release];
[myCustomButton release];
[image release];
[navID release];
谁能修复我的代码? :)
最佳答案
来自 the docs:
initWithImage:style:target:action:
试试那个。