I am developing an iOS application and am having problems using the image as an element of the left button on the navigation bar. I tried this as follows:
UIImage *backButtonImage = [UIImage imageNamed:@"backbuttonCB"]; CGRect buttonFrame = CGRectMake(0, 0, backButtonImage.size.width, backButtonImage.size.height); UIButton *backButton = [[UIButton alloc] initWithFrame:buttonFrame]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; UIBarButtonItem *backBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView: backButton]; self.navigationItem.leftBarButtonItem = backBarButtonItem;
When the application starts, the button on the panel is never displayed.
Then I tried to apply this other method as follows.
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backbuttonCB"] style:UIBarButtonItemStylePlain target:nil action:@selector(methodname)];
This method really worked. However, the displayed image was painted blue and did not look the way it was intended. Changing the hue color of this image did not help.
Any idea how I can solve this problem?
EDIT: More info if this helps. This is the first view on the navigation stack. The navigation stack is displayed modally, i.e. There is a previous view controller, and there is a modal indent between the previous view controller and the navigation controller. This is the first view on the navigation stack.
EDIT: PROBLEM FIXED. I think it was an error in xcode, because when I restarted xcode and tested it using the actual device instead of the emulator, it worked fine. However, it still does not work on the emulator.
ios cocoa-touch uinavigationbar uibarbuttonitem
sosale151
source share