gpt4 book ai didi

uinavigationcontroller - 当 UINavigationController 以模态呈现时 UIBarButtonItems 移动位置

转载 作者:行者123 更新时间:2023-12-03 23:55:49 26 4
gpt4 key购买 nike

我正在展示一个 UINavigationController模态地,从 iOS 应用程序扩展中:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];       
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:nav animated:YES completion:nil];

当导航 Controller 出现时,其根 View Controller 的 UIBarButtonItems跳跃位置:

Jumping buttons

我正在创建和添加按钮 viewDidLoad .它们只是标准的条形按钮项目:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];

我没有覆盖 viewDidAppear (这似乎是按钮跳跃的点)。

在我的应用程序中呈现相同的导航 Controller /根 View Controller ,而不是应用程序扩展,不会给我同样的问题。有什么想法吗?

最佳答案

我希望其他人找到更好的方法来做到这一点,但我目前的解决方案是创建独立按钮,然后使用 [[UIBarButtonItem alloc] initWithCustomView:]与按钮。不理想,缩进仍然存在,但不再发生奇怪的跳跃。

如果缩进让您感到困扰,您还可以在按钮外侧设置负固定空间,将它们移近边缘。

这是一个包含垫片的示例:

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
<other button config here, set targets, whatever>
[button sizeToFit];
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:button];
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[fixedSpace setWidth:-8.0f];

self.navigationItem.leftBarButtonItems = @[fixedSpace, leftBarButton];

这只发生在我的共享扩展上,我没有任何与从分离的 Controller 或类似的东西呈现相关的问题。

关于uinavigationcontroller - 当 UINavigationController 以模态呈现时 UIBarButtonItems 移动位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25415711/

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