Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-28-2009, 08:54 AM   #10 (permalink)
voiperguy
Registered Member
 
Join Date: Aug 2009
Location: Calgary, AB
Posts: 64
voiperguy is on a distinguished road
Default

Ok, now lets Split the bill.

in your .h file, add 2 more outlets:

IBOutlet UITextField * splitPerson;
IBOutlet UILabel * splitAmount;

In your .xib file, add another Text Field and a label "Split" to the left of your new field. Add another Label for the splitAmount.

Make your connections.

In your .m file, in the (void)viewDidLoad section, add this line:
splitPerson.delegate = self;
(again, this will release the keyboard when pressing Done).

within the (void)pickerViewUIPickerView *)...if you followed the previous post for this topic, you will have a line... totalAmount.text = [NSString...blablabla

under that line, enter this:

float splitTotal = (([billTotal.text floatValue] + [taxTotal.text floatValue] + tipTotal) / [splitPerson.text floatValue]);
splitAmount.text = [NSString stringWithFormat:@"$%.2f", splitTotal];

Build & Go.

Now you should have your TipCalc fully operational. Enter your bill, tax and how many people to split...scroll the % you want...and presto... you now have all your 'labels' filled with the results.

This isn't full proof. If you put a "0" in for the Split, in your splitAmount label, you will see the result "#inf". The coding needs an "if/else" statement, but I'm not that Xcode savvy yet

This was the "Easy" way of doing the split. I would really appreciate if someone could expand on this and show us how to not use a UITextField to input the Split #, but use the PickerView (with 2 scrolling areas), left side for the tip % and the right side for the splitPerson 1-2-3-4..10, etc.
voiperguy is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,178
Threads: 93,918
Posts: 402,138
Top Poster: BrianSlick (7,966)
Welcome to our newest member, HugoMSousa
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.