gpt4 book ai didi

iphone - 将 UIBarButtonItems 添加到工具栏时出现问题

转载 作者:太空狗 更新时间:2023-10-30 03:20:52 29 4
gpt4 key购买 nike

我有一个带有 UITableViewController 的 UINavigationController。我想在底部显示一个带有 UIBarButtonItem 的工具栏。工具栏出现了,但按钮不会出现。谁知道为什么?

  - (void)viewDidLoad {
[super viewDidLoad];
[[self navigationItem] setTitle:@"Selections List"];
[[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addProjectSearch:)] autorelease]];
[[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];
[[super tableView] setDataSource: self];
[[super tableView] setDelegate: self];

//Toolbar
UIBarButtonItem * logoutButton = [[[UIBarButtonItem alloc] initWithTitle:@"Log out" style:UIBarButtonItemStylePlain target:self action:@selector(logOut:)]autorelease];
NSMutableArray * arr = [NSMutableArray arrayWithObjects:logoutButton, nil];
[[self navigationController] setToolbarHidden: NO animated:YES];
[[self navigationController] setToolbarItems:arr animated:YES];
}

最佳答案

替换这一行:

[[self navigationController] setToolbarItems:arr animated:YES];

用这个:

[self setToolbarItems:arr animated:YES];

一般来说,您应该在您推送的每个单独的 View Controller 上设置 toolbarItems,而不是在您的 UINavigationController 本身上。

关于iphone - 将 UIBarButtonItems 添加到工具栏时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2475290/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com