如何在objective-c的工具栏按钮上显示值? [英] how to show value on button of toolbar in objective-c?

查看:101
本文介绍了如何在objective-c的工具栏按钮上显示值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做账单项目.我可以滚动浏览很多账单,每张账单上都有很多带有数量和价格的商品.在该按钮上,工具栏上还有许多按钮.账单的总价是其中的1个按钮,而我不知道如何在此按钮上显示总价的数量!

I am doing project of bill. there are many bills that i can scroll and each bill have many items with quantity and price. At the button, there are also many buttons on toolbar. Total Price of bill is 1 button among them, and i don't know how to show the number of total price on this button !

推荐答案

UIButton具有currentTitle属性,您应该能够从中获取标题.

A UIButton has a currentTitle-property and you should be able to get the title from that.

UIBarButtonItem具有一个可能性标题属性,它是一个NSSet,其中包含条形按钮可能具有的所有可能的标题.如果只是一个标题,则可以通过以下功能检索该标题:

A UIBarButtonItem has a possibleTitles-property which is an NSSet containing all possible titles the bar button might have. If it is simply one then you might retrieve this title by the following function:

NSString *buttontitle = [myBarButtonItem.possibleTitles anyObject];

如果包含更多内容,则先将其转换为数组,然后检索所需的标题:

if it contains more then first transform it to an array and then retrieve the title you need:

NSArray *titlesArray = [myBarButtonItem.possibleTitles allObjects];

如果您知道标题可能包含什么标题,则可以使用此标题:

if you know what title it might contain you might want to use this:

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

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

Hope this helps. Good luck.

这篇关于如何在objective-c的工具栏按钮上显示值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆