- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 iOS 8 中使用 UISearchController,当我制作它的 UISearchBar 时,我的表的标题 View 一切正常。但是现在我需要它在我的 UINavigationBar 的左栏按钮中(不能是标题 View ,因为当我放大导航栏时垂直居中)。当我将 UISearchBar 包裹在 UIBarButtonItem 中时,它大于屏幕的宽度。
我认为这与我的 View Controller 有关,该 View Controller 是从启用了大小类的 Storyboard初始化的,这意味着我的框架直到 viewDidLayoutSubviews
才设置。但是,我在工具栏中的分段控件也遇到了同样的问题,我只是在 viewDidLayoutSubviews
的工具栏上调用了 sizeToFit
并修复了工具栏。当我对搜索栏执行相同操作时,它仍然会部分绘制在屏幕外。 Apple 在他们的一些 iPad 应用程序中这样做,但如何做到这一点?
注意:我可以破解它以将其全部显示在屏幕上,但我必须将其包装在另一个 View 中,但颜色会消失,看起来不对劲,我认为动画已关闭。
最佳答案
您需要使用 UIBarButtonSystemItemFixedSpace 创建一个 UIBarButtonItem,宽度为 -10,这将删除 10 px 填充。
UIBarButtonItem *Spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[Spacer setWidth:-10];
UISearchBar *searchBar= [[UISearchBar alloc] initWithFrame:CGRectMake(0, 5, self.view.frame.size.width-10, 39)];
UIBarButtonItem *searchBarItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:Spacer,searchBarItem,nil];
关于ios - 如何在 UIBarButtonItem 中放置 UISearchBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32001151/
我有一个简单的 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
我是一名优秀的程序员,十分优秀!