I am looking to create a bar with a couple of buttons at the top of the iPhone interface just under the statusBar, the controller is a simple UIViewController so this is a bar for buttons not for navigation. I have got things working but it feels a little clunky and I was wondering if I was doing it right and not missing any shortcuts.
- There is no action / selector: set yet as I am just setting this up.
- I will probably remove the NSArray convenience method and add an alloc/release.
Code:
- (void)loadView {
// VIEW
UIView *tempView = [[UIView alloc] initWithFrame:screenFrame];
// NAV BAR
UINavigationBar *tempNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[tempNavigationBar setBarStyle:UIBarStyleBlack];
UIBarButtonItem *testButton = [[UIBarButtonItem alloc] initWithTitle:@"TEST" style:UIBarButtonItemStyleBordered target:self action:nil];
UINavigationItem *navItem = [[UINavigationItem alloc] init];
[navItem setLeftBarButtonItem:testButton];
[testButton release];
[tempNavigationBar setItems:[NSArray arrayWithObject:navItem]];
[tempView addSubview:tempNavigationBar];
[tempNavigationBar release];
[navItem release];
[self setView:tempView];
[tempView release];
}