【问题标题】:UIButton in Toolbar iosios工具栏中的UIButton
【发布时间】:2014-01-06 08:54:05
【问题描述】:

可以在工具栏中以编程方式添加带有背景的UIButton,当我点击按钮时,它会显示一个uiActionSheet,让我从相机拍照或从照片库中,当我选择一张图片时,它会返回视图,并且工具栏中的 UIButton 的背景会发生变化。

【问题讨论】:

  • 你应该看看UIBarButton
  • 代替它在 xib 的工具栏中添加 UIButton。并根据需要以编程方式更改其属性。
  • 你必须尝试什么???只需在谷歌上搜索,您会发现很多示例以在工具栏上添加按钮,然后搜索 UIAlertView 及其委托方法,您将获得所需的所有功能:) 一切顺利:) stackoverflow.com/questions/14251224/…
  • 如果我想更改按钮的背景图像,我认为我不能使用 UIBarButton,这就是为什么我想添加一个 uibutton
  • 你在说导航栏,对。然后你必须使用 UIBarButton,然后,清楚你想用按钮做什么

标签: ios


【解决方案1】:

UIButton 创建UIBarButton

NSMutableArray *mutableItem = [[NSMutableArray alloc]initWithArray:toolbar.items];
UIBarButton *bookmark = [[UIBarButtonItem alloc] initWithCustomView:_m_bmBtn];
[mutableItem addObject:bookmark];
self.m_toolbarTop.items= mutableItem;

隐藏/显示另一个按钮:

  1. button.hidden = YES/ NO.

  2. 删除mutableItem 中的项目并设置:self.m_toolbarTop.items= mutableItem;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    相关资源
    最近更新 更多