【发布时间】:2015-04-22 11:01:39
【问题描述】:
在导航栏中显示带有 UIBarButtonSystemItemCompose 按钮的新视图时,位置会稍微偏离并在视图进入视图后进行调整。
我认为这是 iOS 中的一个错误(使用的是 8.3 版)。它仅在使用 UIBarButtonSystemItemCompose 时发生。其他类型的按钮(系统、文本或自定义)不会发生这种情况。
复制此错误所需的唯一代码是将此 ViewController 代码与将要显示的视图一起使用:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBarButtonItem* composeBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera
target:nil
action:nil];
[self.navigationItem setRightBarButtonItem:composeBarButtonItem animated:YES];
}
@end
我在 GitHub 上创建了一个存储库,使用最少的代码来重现该问题:https://github.com/jvdvleuten/iOSComposeBarButtonItemBug
看起来与此相关:UIBarButtonItems shift position when UINavigationController is presented modally,除了我的错误仅在使用 UIBarButtonSystemItemCompose 时出现。
有什么想法吗?
【问题讨论】:
-
ya..当您使用 compose 作为样式时,这是一个错误...但我认为您应该使用
viewDiidAppear来处理此代码... -
不,当您使用viewDidApear中的代码时,视图会在没有按钮的情况下进入视图。这不是标准的。
-
是的,我知道......但它现在是一个解决方案......而不是那种恼人的观点......那是更好的解决方案......或者使用 sergey Kuryanov 的答案作为解决方案
-
我现在正在使用撰写按钮的图像,它可以工作。我今天会试试 Sergey 的答案。
-
好的...这是您使用 compose 图像的最后一个选项...我知道它的工作原理和魅力
标签: ios objective-c uinavigationcontroller uibarbuttonitem uibarbuttonsystemitem