【问题标题】:how to show value on button of toolbar in objective-c?如何在objective-c中的工具栏按钮上显示值?
【发布时间】:2012-08-16 08:31:21
【问题描述】:

我正在做账单项目。我可以滚动很多账单,每张账单都有很多数量和价格的项目。在按钮上,工具栏上也有很多按钮。账单总价是其中的1个按钮,我不知道如何在这个按钮上显示总价的数量!

【问题讨论】:

    标签: iphone uibutton uitoolbar uitoolbaritem uibuttonbaritem


    【解决方案1】:

    一个 UIButton 有一个 currentTitle-property,你应该能够从中获取标题。

    UIBarButtonItem 有一个 possibleTitles-property,它是一个 NSSet,其中包含栏按钮可能具有的所有可能的标题。如果它只是一个,那么您可以通过以下函数检索此标题:

    NSString *buttontitle = [myBarButtonItem.possibleTitles anyObject];
    

    如果它包含更多,则首先将其转换为数组,然后检索您需要的标题:

    NSArray *titlesArray = [myBarButtonItem.possibleTitles allObjects];
    

    如果你知道它可能包含什么标题,你可能想使用这个:

    Bool *expectedTitleFound = [myBarButtonItem.possibleTitles contains:@"MyTitle"];
    

    希望这会有所帮助。祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-29
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多