У меня есть этот код, который изменяет заднюю кнопку моего UINavigationBarвозврата кнопки из UINavigationBar
// Set the custom back button
UIImage *buttonImage = [UIImage imageNamed:@"backag.png"];
//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"selback.png"] forState:UIControlStateHighlighted];
button.adjustsImageWhenDisabled = NO;
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, 30, 30);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
// Cleanup
[customBarItem release];
Если я положил его в методе viewDidLoad он прекрасно работает. Однако, когда я загружаю следующий вид, появляется старая кнопка стиля. Чтобы исправить это, я попытался поместить этот код в метод viewDidLoad следующего вида, но тогда ни одна кнопка не видна.
Любые идеи относительно того, что может быть причиной этого?
Спасибо!