I am trying to create a toolbar programmatically in a class that subclasses ABPersonViewController. Here is what I have done.
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStyleBordered target:self action:@selector(onToolbarTapped:)];
NSArray *items = [NSArray arrayWithObjects: customItem, nil];
[self.navigationController.toolbar setItems:items animated:NO];
//[self setToolbarItems:[NSArray arrayWithObject:items]];
self.navigationController.toolbar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController setToolbarHidden:NO animated:YES];
The toolbar doesn't appear. What am I doing wrong here.
Edit: I have edited my code as follows
UIToolbar *toolbar = [[[UIToolbar alloc] init]autorelease];
toolbar.barStyle = UIBarStyleBlackOpaque;
toolbar.tintColor = [UIColor blackColor];
toolbar.frame = CGRectMake(0, 372, self.view.frame.size.width, 45);
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:unblockContact style:UIBarButtonItemStyleBordered target:self action:@selector(onToolbarTapped:)];
customItem.tintColor = [UIColor blackColor];
NSArray *items = [NSArray arrayWithObjects:customItem, nil];
[toolbar setItems:items animated:NO];
[self.view addSubview:toolbar];
[customItem release];
How can I make the barbuttonitem occupy the entire toolbar. The user shouldn't feel that there is a barbuttonitem on the toolbar. Could I do this way, or is there an alternate way? Help needed. Thanks.