ios - xcode 4.6 2 textfield equals to 100 -


i'm using xcode 4.6, , have little problem where. in app have 2 text fields 1 says vg , other says pg (the vg , pg equal 100). user able put on each text field percentage amount, lets user inputs on vg text field number 10, automatically pg change whatever number has correct amount equal 100. calculates vg being 1 input , pg showing result, if try other way around, doesn’t work. if user wants change value pg , result on vg text field, show calculation result vg being input. make calculation go both ways. have set floats.

-(void)textfieldshoudendediting (uitextfield *)textfield { float = [vg.text floatvalue]; float b = [pg.text floatvalue]; float result1 = (100 – a) pg.text = [nsstring stringwithformat:@”%.0f”, result1]; floar result2 = (100 – b) vg.text 0 [nsstring stringwithformat:@”%.0f”, result2]; } 

thank you

you need test textfield parameter see 1 being edited.

something like:

if (textfield == pg) {     //update vg } else if (textfield == vg) {     //update pg } else {     //if ever have other textfields , want } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -