how to show value on button of toolbar in objective-c?

烈酒焚心 提交于 2019-12-13 21:24:56

问题


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 !


回答1:


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

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.



来源:https://stackoverflow.com/questions/11983340/how-to-show-value-on-button-of-toolbar-in-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!