Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

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

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 !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...