当UINavigationController以模态方式呈现时,UIBarButtonItems移位

当UINavigationController以模态方式呈现时,UIBarButtonItems移位,第1张

概述我在iOS应用程式扩充功能中以模态方式呈现UINavigationController: UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; nav.modalPresentationStyle = UIModalPresentationFormSh 我在iOS应用程式扩充功能中以模态方式呈现UINavigationController:
UINavigationController *nav = [[UINavigationController alloc] initWithRootVIEwController:vc];       nav.modalPresentationStyle = UIModalPresentationFormSheet;nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;[self presentVIEwController:nav animated:YES completion:nil];

当导航控制器出现时,其根视图控制器的UIbarbuttonItems跳转位置:

我正在创建并添加vIEwDIDLoad中的按钮.它们只是标准的按钮项目:

self.navigationItem.rightbarbuttonItem = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem:UIbarbuttonSystemItemDone target:self action:@selector(done)];

我不会覆盖vIEwDIDAppear(这似乎是按钮跳跃的点).

在我的应用程序内提交相同的导航控制器/根视图控制器,而不是应用程序扩展,不会给我同样的问题.有任何想法吗?

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

如果您的缩位困扰您,您还可以在按钮的外侧设置负的固定空间,使其更靠近边缘.

这里有一个例子,包括spacer:

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];

这只会在我的分机扩展上发生,我没有任何与分离的控制器或任何类似的内容相关的问题.

总结

以上是内存溢出为你收集整理的当UINavigationController以模态方式呈现时,UIBarButtonItems移位全部内容,希望文章能够帮你解决当UINavigationController以模态方式呈现时,UIBarButtonItems移位所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1110764.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存