다음 문제가 발생했습니다.장치에서 UIBarButtonItem 모양이 작동하지 않습니다.
내 응용 프로그램의 모양을 사용자 정의하고 있습니다. 이제 탐색 바에서 백 버튼의 배경을 변경하고 싶습니다. 시뮬레이터에서 코드를 실행하면 작동합니다. 하지만 장치에서 실행하면 아무 것도 변경되지 않습니다. 이것이 어떻게 가능한지?
나는 이미지 파일의 맞춤법, 특히 모자를 확인 내 아이폰 4S 아이폰 OS 5.0.1
#import "test.h"
#import "InfoButton.h"
@implementation test
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
if([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
//iOS 5 new UINavigationBar custom background
UIImage *navi = [UIImage imageNamed:@"navbar.png"];
[self.navigationController.navigationBar setBackgroundImage:navi forBarMetrics: UIBarMetricsDefault];
UIImage *toolbarBackButtonBackgroundPortrait = [[UIImage imageNamed:@"nav_back.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 17, 0, 6)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:toolbarBackButtonBackgroundPortrait forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}
[super viewDidLoad];
UIButton * infoDarkButtonType = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
infoDarkButtonType.frame = CGRectMake(0.0, 0.0, 30.0, 25.0);
infoDarkButtonType.backgroundColor = [UIColor clearColor];
[infoDarkButtonType addTarget:self action:@selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] initWithCustomView:infoDarkButtonType];
self.navigationItem.rightBarButtonItem = infoButton;
[infoDarkButtonType release];
[infoButton release];
}
대단히 감사합니다. nav_bar.PNG에 저장 했으므로 이제 작동합니다! – AmiiQo