我在看不到状态栏iPhone界面的顶部创建了几个按钮的一间酒吧,控制器是一个简单的UIViewController所以这是不是导航按钮了吧。 我已经得到的东西的工作,但感觉有点麻烦,我想知道如果我这样做是正确且没有遗漏任何快捷方式。
- 没有动作/选择:设置但是作为我只是设置此功能。
- 我可能会删除NSArray的简便方法,并添加分配/释放。
码:
- (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];
}