我使用以下代码在视图中添加了一个导航栏:
- (void)viewDidLoad
{
[super viewDidLoad];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"Load Colors"];
[navBar pushNavigationItem:navItem animated:NO];
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(toggleEdit:)];
navItem.rightBarButtonItem = editButton;
[self.view addSubview:navBar];
CGRect tableFrame = self.tableView.frame;
tableFrame.origin.y = tableFrame.origin.y +45;
self.tableView.frame = tableFrame;
}
正如您在下图中看到的那样,它出现在我的 tableView 上。我该如何解决?