- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我喜欢将我的 View 创建为独立的 Xib 文件,然后实例化它们并添加为 subview 。
因此,当使用 UINavigationBar
时,我希望能够做同样的事情,首先创建我的自定义 View - 从 Xib - 然后将其作为自定义 View 添加到 UIBarButtonItem
:
UIBarButtonItem *anItem = [[UIBarButtonItem alloc] initWithCustomView:_myCustomView];
self.navigationBar.topItem.rightBarButtonItems = @[ anItem, anotherItem ];
_myCustomView
使用自动布局(AL),我认为这没问题。不是这样。我已经尝试了几乎所有的东西。没有任何效果。我什至尝试将自定义 View 添加为具有导航栏的 Controller 的 subview 。考虑到作为 View 层次结构中的兄弟,AL 会将其视为
UINavigationBar
之外的常规 View 。 .
updateViewConstraints
被调用但从未应用。 View 的初始帧停留在
CGRectZero
.就好像 AL 看到 View 位于
UINavigationBar
之上,即使作为 sibling ,并决定它不需要布局。
bringSubviewToFront
,
translatesAutoresizingMaskIntoConstraintstranslatesAutoresizingMaskIntoConstraints
, 等等。后者给了可爱的:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. MyNavigationBar's implementation of -layoutSubviews needs to call super.'
customView
在
UIBarButtonItem
?如果是这样,如何?
最佳答案
看起来像 iOS Autolayout and UIToolbar/UIBarButtonItems 的副本UIBarButtonItems
不继承自 UIView
,因此可能不完全支持在其中使用基于自动布局的自定义 View 。听起来你必须做预先自动布局的事情,直到问题得到解决。我建议提交一个错误。
编辑:通过预自动布局,我的意思是直接操作 View 的框架。
关于uinavigationbar - 使用 UINavigationBar 和 UIBarButtonItem 自动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17729947/
我有一个简单的 UITableViewController 和一个 NavigationController 作为 Root View Controller 。我在导航栏中添加了“选项”UIBarBu
我正在尝试 this Apple tutorial但我发现了一个错误。有人可以帮助我吗? Disable Saving When the User Doesn't Enter an Item Name
我有一个 UIBarButtonItem 和 UIButton 作为自定义 View 。 UIButton 上有一个 addTarget:action:。在 Action 中,我展示了一个弹出窗口。我
我正在学习 iOS 开发,有两个简单且相关的问题: 1. 如何将多行项目添加到一个 UIToolBar 中,这可能吗?我想要一个 UISearchBar 和一个 UIToolbar 上的两行 UIBa
这就是我自定义 UIBarButtonItem 的方式: if DBAppSettings.imageViewForCartBarButtonItem == nil { DBAppSettin
有没有办法让UIBarButtonItem独家触摸?目前,您可以同时选择多个,但它不断使我的应用程序崩溃。 最佳答案 比继承导航栏更简单的方法,但思路相同; for(UIView *temp in s
如何在 uitoolbar 内旋转 uibarbuttonitem?因为我旋转了 uitoolbar(现在是垂直的)并且我的栏按钮项目也旋转了,但我不希望这样。 谢谢 最佳答案 UIBarButton
我创建了一个具有半透明黑色样式的工具栏,如下所示: UIToolbar *toolbar = [UIToolbar new]; toolbar.barStyle = UIBarStyleBlack;
有没有办法以动画方式启用或禁用按钮?我尝试了以下方法但没有成功。我猜测此时启用的属性无法像不透明度一样进行动画 - 但我希望我是错的。 [UIView beginAnimations:nil
在 IB 中,我可以选择一个 UIBarButtonItem,将其设置为“普通”、“自定义”并应用图像,它在 UIToolbar 或 UINavigationBar 中看起来不错。 当我尝试在代码中执
我需要更改 UIBarButtonItem 标题的字体。目前是 barbuttonItem.customView = customLabel。现在我希望添加一个选择器和目标,以便我可以获得 touch
我正在尝试偏移应用程序中的 UIBarButtonItems,由于我用于导航栏的图像,我需要它们稍微偏移,以便它们全部正确排列。我已经成功地做到了这一点: [[UINavigationBar appe
我希望使用标签访问 UIToolbar 上的 UIBarButtonItem。代码如下所示 UIBarButtonItem *myBarButtonItem=(UIBarButtonItem*)myU
我有一个自定义按钮,我想添加到导航栏上。到目前为止,这就是我的 RootViewController 中的内容(它继承了 UIViewController,UINavigationController
每当“userInput”UITextField 中没有输入时,我尝试禁用我的发送按钮(工具栏中的 UIBarButtonItem),并在有输入时启用它。这是我写的代码 - 我不太明白为什么它不起作用
我添加了一个 UIToolbar 实例和其顶部的按钮。每个按钮都属于 UIBarButtonItem 类。 我的要求是每个按钮都有一个自定义布局,我不想使用Apple提供的原生按钮样式。所以我在 In
你能看到按钮左边的距离吗?如何消除这个距离? 最佳答案 在按钮左侧添加一个间隔符,例如: UIBarButtonItem *backButtonItem = ....; UIBarButtonItem
我知道有些人已经问过这个问题,但到目前为止,答案还不是很具体。 显然苹果已经使导航栏的点击区域比实际更大,但我认为它不应该那么大。 在我的应用程序中,导航栏正下方有一个 TableView,您可以一直
我已经为 UINavigationBar 设置了自定义色调颜色(在 UINavigationController 内),这又为 UIBarButtonItems 设置适当的匹配颜色。插入 UINavi
我有一个带有两个 View 的导航栏应用程序:父 View 和 subview 。在 subview 中,我在右上角添加一个按钮,如下所示: - (void)viewDidLoad { UIB
我是一名优秀的程序员,十分优秀!