UINavigationItem leftBarButtonItem
@property(nonatomic, retain) UIBarButtonItem *leftBarButtonItem
Discussion of [UINavigationItem leftBarButtonItem]
In iOS 5.0 and later, the contents of this property always refer to the first bar button item in the leftBarButtonItems array. Assigning a new value to this property replaces the first item in the leftBarButtonItems array with the new value. Setting this property to nil removes the first item in the array. If the bar button item is already in the array, it is moved from its current location to the front of the array.
Prior to iOS 5.0, this property contained the single bar item to display on the left side of the navigation bar instead of the back button.
UINavigationItem leftBarButtonItem example.
Hiding UInavigationItem's bar button
This works I tried it myself
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = YES;
This works I tried it myself
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = YES;
Example of [UINavigationItem leftBarButtonItem].
CGRect rect = CGRectMake(10, 0, 30, 30);
self.backButton = [[UIButton alloc] initWithFrame:rect];
[self.backButton setImage:[UIImage imageNamed:@"back_arrow.png"]
forState:UIControlStateNormal];
self.backButton.contentMode = UIViewContentModeCenter;
[self.backButton addTarget:self
action:@selector(backButtonAction:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
self.navigationItem.leftBarButtonItem = backButtonItem;
self.navigationItem.hidesBackButton = YES;
self.backButton = [[UIButton alloc] initWithFrame:rect];
[self.backButton setImage:[UIImage imageNamed:@"back_arrow.png"]
forState:UIControlStateNormal];
self.backButton.contentMode = UIViewContentModeCenter;
[self.backButton addTarget:self
action:@selector(backButtonAction:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
self.navigationItem.leftBarButtonItem = backButtonItem;
self.navigationItem.hidesBackButton = YES;
UINavigationItem leftBarButtonItem example.
//Next Button
btnNext = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemPlay target:self action:@selector(next:)];
[items addObject:btnNext];
[tool setItems:items];
tool.barStyle =UIBarStyleDefault;
tool.backgroundColor = [UIColor clearColor];
//self.navigationItem.leftBarButtonItem.customView = tool;
//self.navigationItem.titleView = tool;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tool];
btnNext = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemPlay target:self action:@selector(next:)];
[items addObject:btnNext];
[tool setItems:items];
tool.barStyle =UIBarStyleDefault;
tool.backgroundColor = [UIColor clearColor];
//self.navigationItem.leftBarButtonItem.customView = tool;
//self.navigationItem.titleView = tool;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tool];