gpt4 book ai didi

ios - iPhone 导航栏不显示设备上的所有按钮

转载 作者:可可西里 更新时间:2023-11-01 04:52:28 24 4
gpt4 key购买 nike

在 iPhone 模拟器的纵向模式或设备的横向模式下,它显示所有导航栏按钮,但在设备的纵向模式下使用时,该按钮不显示。下面是导航栏的图像。

Simulator shows button

Device doesn't show button

我用于测试的设备是运行 iOS 6.1.3 (10B329) 的 iPhone 4S。我使用的模拟器是 Version 7.0 (463.9.4) running iOS 6.0/6.1。

我正在考虑在编辑模式下删除“搜索”按钮,但我更愿意让用户在任何模式下都可以使用此选项。

感谢任何帮助或见解,谢谢。

编辑:右侧按钮最初是在 viewDidLoad: 中为 ViewController 创建和添加的,如下所示:

_deleteBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteRows:)];
_deleteBarButtonItem.tintColor = [UIColor redColor];

_searchBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchButtonClicked:)];

self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, self.editButtonItem];

进入编辑模式时:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];

if (self.tableView.isEditing) {
// turn off editing
_deleteBarButtonItem.enabled = NO;
[self.tableView setEditing:NO animated:animated];
[self.editButtonItem setStyle:UIBarButtonItemStylePlain];
self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, self.editButtonItem];
} else {
// turn on editing
[self.tableView setEditing:YES animated:animated];
[self.editButtonItem setStyle:UIBarButtonItemStyleDone];
self.navigationItem.rightBarButtonItems = @[_searchBarButtonItem, _deleteBarButtonItem, self.editButtonItem];
}
}

最佳答案

老实说,这很好奇。也许是标题的某些属性使其占据主导地位。根据我的经验,最好在“编辑模式”期间选择较少的选项。如果您决定走那条路,这里有一些代码可能会有所帮助。 (当然,您的变量名很可能不同)

// Get the reference to the current toolbar buttons
NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy];

if (editing) {
// This is how you remove the button from the toolbar and animate it
[toolbarButtons removeObject:self.myButton];
[self setToolbarItems:toolbarButtons animated:YES];
} else {
// This is how you add the button to the toolbar and animate it
if (![toolbarButtons containsObject:self.myButton]) {
// The following line adds the object to the end of the array.
// If you want to add the button somewhere else, use the `insertObject:atIndex:`
// method instead of the `addObject` method.
[toolbarButtons addObject:self.myButton];
[self setToolbarItems:toolbarButtons animated:YES];
}
}

关于ios - iPhone 导航栏不显示设备上的所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19771392/

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