0
我有一些困難,以設置圖像..有什麼奇怪的,因爲在不同的控制器,它的工作。可能self.navigationItem
是無效的,但爲什麼如果我只是推ViewController
從不同ViewController
..?設置後退按鈕自定義Outlook不起作用
我已經試過:
// preview buttonImage shows that image is correct and exists
UIImage *buttonImage = [[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"TEST" style:UIBarButtonItemStylePlain target:nil action:NULL];
[buttonItem setBackButtonBackgroundImage:buttonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
self.navigationItem.backBarButtonItem = buttonItem;
不同的方法:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"TEST" forState:UIControlStateNormal];
[button setImage:buttonImage forState:UIControlStateNormal];
buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.backBarButtonItem = buttonItem;
我想,也許self.navigationItem是錯誤的,但它似乎存在:
NSLog(@"%@, %@", self.navigationItem, self.navigationItem.backBarButtonItem);
--CONSOLE-- MyApp[56574:3827402] <UINavigationItem: 0x7b6ecd10>, <UIBarButtonItem: 0x7b6f01c0>
我甚至試圖設置:
self.navigationItem.backBarButtonItem = nil;
什麼也似乎沒有工作。
- 編輯 -
但是下面的代碼做的工作:
[self.navigationItem setHidesBackButton:YES];
什麼建議,那self.navigationItem
是有效的。