gpt4 book ai didi

ios - Interface Builder 错误地调整导航项

转载 作者:行者123 更新时间:2023-11-30 13:46:19 26 4
gpt4 key购买 nike

我已经搞乱这个问题有一段时间了,但我不知道是什么导致了这个问题。我有一个嵌入在 UINavigationController 中的 UIViewController,并且在生成的 UIViewController 上有两个 UINavigationItems:

1:左按钮是默认的“完成”按钮,没有图像 - 看起来很好2:右键是一个带有30x30图像的普通按钮

enter image description here

这些按钮未连接到任何 IBOutlet,并且不会在 Swift 代码中进行更改。然而,当代码被编译并在模拟器上运行时,右侧按钮会被按下屏幕。如果删除图像并添加标准文本,则按钮显示正常。

enter image description here

如有任何建议,我们将不胜感激,谢谢

环境详细信息:MacOSX 10.11.2,Xcode 7.2

最佳答案

这就是我在 Objective-C 中所做的,将按钮设置到特定一侧。

UIImage *image = [UIImage imageNamed:@"Notification.png"];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self
action:@selector(goToNotifiationView:)
forControlEvents:UIControlEventTouchUpInside];
button.adjustsImageWhenHighlighted = NO;
UIBarButtonItem *rightButton =
[[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = rightButton;

关于ios - Interface Builder 错误地调整导航项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34884697/

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