问题标签 [rightbarbuttonitem]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1853 浏览

objective-c - 右栏按钮项目未垂直对齐

我正在使用以下代码从 viewController 中设置 rightbarbuttonitem:

如图所示:

导航项

如您所见,出现的按钮未与左按钮项或标题垂直对齐。

我还尝试使用此处提到的代码调整对齐方式:

但这会删除自定义字体并将按钮移动得更高。

带调整的导航项

如何设置对齐的 rightbarbuttonitem 并使用 UIAppearance 代理维护自定义字体集?

编辑:

我什至尝试使用

但结果与第一张图片完全一样。

更新(9 月 20 日):

看来我将不得不接受亚历山大的回答,有人有更清洁的解决方案吗?

0 投票
1 回答
443 浏览

ios8 - 在 iOS8 中禁用时 rightBarButtonItem 不会改变颜色

在 iOS8 中禁用 rightBarButtonItem 不会像在 iOS7 中那样将其颜色更改为灰色。在禁用时,除了手动更改文本颜色颜色之外,我还需要做更多的事情来更改其颜色。

0 投票
2 回答
1841 浏览

ios - 如何添加导航栏“加号”按钮,并在代码中使用

我在导航控制器中有一个表格视图,顶部有一个导航栏。我想在此导航栏的右侧添加一个加号按钮,并在按下该按钮时发布 NSLog。但是,所有建议以编程方式添加导航栏的在线资源都失败了。我怎样才能做到这一点?

所有帮助表示赞赏。

编辑:这是我在 viewDidLoad 方法中使用的一些代码。所以你知道,我只是添加了这段代码,没有做任何其他事情:

编辑 2:当我创建项目时,在 Interface Builder 中,我创建了一个导航控制器,将我的 FirstViewController 左侧的箭头移动到导航控制器,然后删除了我的 FirstViewController。这会阻止代码工作吗?

0 投票
1 回答
349 浏览

ios - UILabel 作为 UIBarButtonItem.customView 的子视图在呈现视图控制器时不会变暗

我有一个问题,当视图控制器以模态方式呈现时,导航栏中的 UILabel 没有正确着色。

UILabel在导航栏中,作为一个UIButton的子视图,它是UIBarButtonItem的子视图,也就是导航控制器的rightBarButtonItem;查看层次结构:

需要明确的是,除了呈现模态期间的标签色调外,一切正常。在呈现视图控制器之前,购物车被染成蓝色,包含 # 购物车项目的标签也是如此。当模态出现时,购物车图像变暗,但标签保持蓝色。

我会发布图片,但我没有足够的声誉,对不起。

我试过的:

  • 在标签上设置色调颜色
  • 设置label.userInteractionEnabled = NO
  • 将 设置label.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed为所有可用值(都没有帮助)
  • 子类化 UIButton 并在期间绘制 # 个购物车项目drawRect
  • 在视图控制器演示期间,在navigationItem.rightBarButtonItem.customView层次结构中查找标签并手动设置 tintAdjustmentMode。

没有任何效果。我没主意了...

这是我创建 UIBarButtonItem 的代码:

有任何想法吗?

0 投票
2 回答
87 浏览

ios - 在 rightBarButtonItems 中添加 BarButton

我已经创建了 4 个带有图像的 BarButtons,并且当我添加到导航栏时。它显示了项目之间的大间隙以及如何消除图像之间的间隙。

0 投票
2 回答
832 浏览

ios - 在导航栏上将 MKUserTrackingBarButtonItem 移动到右侧

当 MKUserTrackingBarButtonItem 附加到 navigationItem.rightBarButtonItem 时,有没有办法移动它?现在它看起来像这样:

我的形象

我希望它看起来更像 Apple 的地图(编辑:更接近边缘):

在此处输入图像描述

有没有办法做到这一点?我试过 ImageInsets 没有运气。

编辑:这是 viewDidLoad 中的代码

0 投票
1 回答
292 浏览

ios - segue from multiple bar button items

I have a view controller with 1 leftBarButtonItem and 2 rightBarButton Items.

I have implemented them using this code.

The menuButtonRight and menuButtonLeft have been added in storyboard. But as i wanted one more right button, i added it programmatically seeing SO questions and this search button is visible when i run the app, bt does not appear in the storyboard.

But now I want to perform a segue from this search button.

The main intent here is to call a newViewController when the search button is pressed.

I was thinking of calling the newViewController directly when the button is clicked. bt m not able to figure out how to do it.

Pls throw some light on this

0 投票
1 回答
249 浏览

ios - UISegmentedControl、rightBarButtonItem 和旋转问题

我正在尝试重新创建(在某种程度上)在 iOS 7 和 iOS 8 上的 Mail.app 上显示的向上和向下箭头。没有太多内容。我只是将 a 插入UISegmentedControl到 aUIBarButtonItem中,就像这样(如果您知道复制该 UI 的更好方法,请告诉我):

setBackgroundImage:注意对和的调用setDividerImage:。它们是必需的,因此控件看起来就像 Mail.app 中的控件。该设置有效:

rightBarButtonItem 看起来很棒!

麻烦的是,它不会在轮换后保持这种状态。在横向使用 iPhone 时,它rightBarButtonItem​​会自动调整大小,看起来破碎并保持这种状态,即使将设备返回到纵向模式:

rightBarButtonItem 看起来不再那么棒了......

控件仍然按计划工作,但是……它看起来不再那么漂亮了。

我已经尝试了很多属性和不同的设置,除了没有为控件背景设置一个空的 UIImage 之外,似乎没有任何效果。如果我注释掉setBackgroundImage:setDividerImage:部分代码,即使在旋转后,控件也会保持其外观:

有效,但没有外观!

但这不是我一直在寻找的 UI。

你知道有什么方法可以达到预期的外观并且仍然有正确的行为吗?或者甚至是什么可能导致调整大小?

0 投票
3 回答
1042 浏览

ios - iphone 6和6+中没有出现右栏按钮

我正在尝试在我的标签栏中添加一个右栏按钮navigationbar,它在 iphone 5 和 5s 设备以及所有模拟器中工作正常。但它没有出现在 iphone 6 和 6+ 设备中。但是它在 iphone 6 和 6+ 的模拟器上运行良好。

这是按钮代码。

您也可以在图像中看到在此处输入图像描述

还有一个清晰的 iphone 6 图像 在此处输入图像描述

看到按钮的边框为 2,甚至没有出现占位符。

0 投票
1 回答
137 浏览

ios - 从一个视图控制器移动到另一个视图控制器时,rightBarButtonItem 似乎会堆叠

我的问题是我rightBarButtonItem在我的故事板中为每个视图创建了一个,rightBarButtonItem在我的应用程序中应该跟踪用户添加到他们的购物清单中的项目的总成本。在我viewDidLoad的第一个中,ViewController我将rightBarButtonItem'scustomView 设置为UILabel. 当移动到另一个时,ViewController我将 ViewController 设置rightBarButtonItem为上一个ViewController。但是,当我回到上一个时ViewControllerViewController's rightBarButtonItem当我尝试更新它时不会改变。相反,它看起来就像我上一次移动时所做的那样,如果我再次移动到同一个 ViewController,第一个 ViewControllerrightBarButtonItem似乎总是比它应该返回的位置落后一步。换句话说,ViewController 的rightBarButtonItem移动到另一个时似乎堆叠ViewController

任何帮助深表感谢。

-- 相关代码:

viewDidLoad - 第一个 ViewController

prepareForSegue - 第一个 ViewController

viewWillDisappear - 第二个 ViewController

sendTotalBackFromOrder - FirstViewController