- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用一个 Storyboard,并且我有一个 Split View,其中主视图是一个 UITableViewController。与 iPad 邮件应用程序一样,我想显示一个 UIToolbar。
我无法通过 Storyboard添加工具栏,但我设法以编程方式添加了它。我还可以将 UILabel 添加到工具栏,但我找不到添加刷新按钮或任何类型的 UIBarButtonItem 的方法。
有什么想法吗?
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setToolbarHidden:NO];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50.0f, 0.0f, 80.0f, 40.0f)];
label.text = @"last updated...";
label.textAlignment = UITextAlignmentCenter;
label.font = [UIFont systemFontOfSize:13.0];
[self.navigationController.toolbar addSubview:label];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStylePlain target:self action:@selector(action:)];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"Item1" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];
NSArray *buttons = @[item1, item2, nil];
[self.navigationController.toolbar setItems:buttons animated:NO];
最佳答案
感谢 Apple iOS 论坛找到了答案!
当您使用导航 Controller 的工具栏时,您必须在 active View Controller 的 toolbarItems
属性上设置工具栏按钮,而不是在实际导航 Controller 的工具栏本身上.
来自UINavigationController
docs :
Displaying a Toolbar
A navigation controller object manages an optional toolbar in its view hierarchy. When displayed, this toolbar obtains its current set of items from the
toolbarItems
property of the active view controller. When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.
例如:
[self setToolbarItems:buttons animated:NO];
关于ios - UIToolbar 不显示 UIBarButtonItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10825572/
我正在创建一个 UIToolbar,上面只放置了一个 UILabel。标签内容是动态的并且可以更改,我想将其集中在 UIToolbar 上。 有人知道 UIToolbar 左侧和右侧的确切边距大小吗?
我正在关注来自 here 的第二条提示.在本技巧中,两个 UIBarButtonItem 被放在一个 UIToolbar 中。最后,将 UIToolbar 添加到 UINavigationBar。现在
我有一个非常顽固的 UIToolbar,无论我尝试如何不同的方法,它都拒绝改变其高度。 我看过这个问题,但它对我不起作用 Is there a way to change the height of
如何制作垂直的 UIToolbar? 最佳答案 子类化 UIToolbar 并执行以下操作: CGFloat DegreesToRadian(CGFloat degrees) { return
是否可以在屏幕顶部放置一个 UIToolbar?示例应用程序类似于“日历”,右侧有“+”,左侧有“日历”按钮。 最佳答案 您可以将 UIToolbar 放置在任何地方。这只是一个 UI View 。
我需要创建一个使用图像作为背景的 UIToolbar 对象。大多数按钮也是图像,并且是矩形的。然而,有一个按钮是圆形的,并且与工具栏重叠,就像 Windows 任务栏上的“开始”按钮一样。见下文。 我
我想显示一个顶部有圆角的UIToolbar,最简单的方法是什么?工具栏未在窗口上对齐;它周围都有边距。谢谢! 最佳答案 非常简单。 首先 - 在 View Controller 的 .h 文件中有一个
我的 View 底部有一个 UIToolbar,并且此工具栏中有一个 UITextField。当我开始编辑此字段时,它隐藏在键盘后面。为了查看我输入的内容,我想在键盘出现时将工具栏向上移动(然后在完成
在我的应用程序中,我有一个工具栏,在某个时刻我想禁用或启用一些按钮。最简单的方法是什么?如何访问 UIToolbar 的 items 属性? 这是我的代码: -(void)addToolbar {
我有一个 UINavigationController,它被推送到 DetailsViewController。在这个DetailsViewController中,我想使用每个UINavigation
昨天下载了 IOS5 SDK,我用来将 UIToolbar 的背景设置为自定义图像的这段代码停止工作。如果我将目标设置为 IOS4.3 及以下,它仍然有效。 [self.bizToolbar inse
我正在尝试放置 UIToolBar在 UINavigationBar . UIToolbar* tempFontSizeToolBar = [[UIToolbar alloc] initWith
我有一个 UItableView,底部有一个工具栏。工具栏有两个按钮,分别是“水果”和“蔬菜”。单击它们将仅显示相应的类别。 我已经设法让显示功能正常工作,但我不知道如何在选择时将按钮设置为 sele
这个问题在这里已经有了答案: How to create this toolbar programmatically [closed] (6 个答案) 关闭 8 年前。 我试图在一个子类 ABPer
我想创建上面的用户界面。具体来说,一个更高的工具栏。但我需要以底层 UI(即内容 View )相应显示(即在工具栏下方)的方式这样做。 我熟悉 iOS 5 中新的 UIAppearance 选项。但是
UI问题在这里;我认为 UIToolbars 应该与状态栏融为一体?还是仅适用于 NavigationControllers? 最佳答案 UIToolBar 在顶部有一条默认的 1px 线(超出范围)
我有一个 UIToolbar。 如果我像这样创建一个 UIBarButton,它会起作用: UIBarButtonItem *button = [[UIBarButtonItem alloc] ini
我希望在用户单击按钮时(在我的例子中是当他们放大照片时)以编程方式将 UIToolbar 添加到 View 。 当我在 click 方法中创建工具栏并添加到 subview 时,它似乎工作正常但是如果
我的 View 上有一个 UITextView,并且可以通过按键盘工具栏上的完成按钮来关闭键盘。此按钮还对文本执行保存。在我的应用程序的最新版本之前,整个事情都运行得很好。我不明白发生了什么事。我怀疑
嘿伙计们,我正在尝试向 UIToolbar 添加文本,但有一个问题:我想更改字体并有 2 行文本(顶行较小,底行较大)。有什么想法如何做到这一点吗? 提前致谢! 最佳答案 您需要创建一个包含自定义 V
我是一名优秀的程序员,十分优秀!