0

I design setting for amount section so my requirements are: 1. the default Amount shall be $0.00. and 2. the max amount shall be $99999.99 and 3. when an amount is entered using the numerical keyboard,the amount shall get populated from right side of the decimal point (cents) to the left side of decimal point(Dollar). For e.g default value is $0.00 and when i put 1 then it should show $0.01 And when i put 2 it should show $0.12 and after that For 3 it should show $1.23 and so on to $99999.99. I am not sure but i think this method should used

-(void)textFieldDidEndEditing:(UITextField *)textField

OR

- (BOOL)textFieldShouldReturn:(UITextField *)textField.

I am little bit weak in coding if possible please give me answer in code that would be better for me.

How can i get this? Need help.

Thanks

AG29
  • 127
  • 1
  • 7

1 Answers1

0
-(IBAction)btnPointPress:(id)sender
{

if([stringMain length] < 10)
{
      stringMain = [[NSString stringWithFormat:stringMain]stringByAppendingFormat:@"."];
        pointCheck = YES;
        pointOnce++;

}

lastString = stringMain;
number = [stringMain doubleValue];
}

This is for adding a decimal point. Now tell me after this what is your requirement ?

IronManGill
  • 7,222
  • 2
  • 31
  • 52
  • @ Gill: thanks. Actually i want to show it in a text field for Iphone Application when user insert number they arrange in required format. – AG29 Oct 11 '12 at 12:42
  • I dont think you can arrange the data on run time ... I think you will be able to do it on some action like that of a button .... – IronManGill Oct 11 '12 at 12:48
  • @ Gill : Its a text field not button. – AG29 Oct 11 '12 at 12:53
  • 1
    I knw so do u want to change the data on the tap of the textfield like on -(void)textFieldDidEndEditing:(UITextField *)textField or on - (BOOL)textFieldShouldReturn:(UITextField *)textField ?? – IronManGill Oct 11 '12 at 12:55
  • @ Gill:Yes, Now you understand what i was trying to say. help me – AG29 Oct 11 '12 at 12:58
  • 1
    In that case take 2 strings .... one will keep the previous value and the other the value the user entered... Then append both the strings to give the result ... u got the general idea ?? – IronManGill Oct 11 '12 at 13:01
  • @ Gill: But how can i set the decimal point and how can i arrange the strings so i would get output in required format. – AG29 Oct 11 '12 at 13:13
  • @ Gill: In which Delegate should i start to write the code. please give me information in detail. Thanks – AG29 Oct 11 '12 at 13:15
  • 1
    textfield.text = [[string1 stringByAppendingString:@" "] stringByAppendingString:textString]; – IronManGill Oct 11 '12 at 13:17
  • @-Gill: how can i set the decimal point for two points? and tell me in which delegate should i start to Edit? – AG29 Oct 11 '12 at 13:21
  • U can also do it on -(void)textFieldDidBeginEditing:(UITextField *)textField – IronManGill Oct 11 '12 at 13:28
  • @ Gill: i set decimal for 2 points because its requirement( e.g 2.22 , 3333.33 like that only for two point). now tell me please how to do it?? – AG29 Oct 11 '12 at 13:32
  • http://stackoverflow.com/questions/9286916/nsstring-validation check this link.... and this 2 http://stackoverflow.com/questions/9295179/adding-a-decimal-point-button-to-an-ios-calculator – IronManGill Oct 11 '12 at 13:49
  • And how to push the number from right side to left side with two decimal digits. – AG29 Oct 12 '12 at 11:34
  • seems interesting but how to use UITextWritingDirectionRightToLeft in my code so that i get my required output with TWO DECIMAL DIGIT??????? – AG29 Oct 12 '12 at 12:31
  • oh! please i am now totally frustrated if possible then please give me whole code . i think its 10 to 20 lines code so please send me it would be better for me.Thanks – AG29 Oct 12 '12 at 12:35
  • @ Gill :And you are awesome man you have lot of knowledge its nice to meet you man. – AG29 Oct 12 '12 at 12:42
  • Thanks @AG29 ill make the code and if possible send it to u by today :)... But Please mail me your whole requirement so that I can compose the simplest solution... meanwhile try on ur own .... – IronManGill Oct 12 '12 at 12:48
  • @ Gill: I design setting for amount section so my requirements are: 1. the default Amount shall be $0.00. and 2. the max amount shall be $99999.99 and 3. when an amount is entered using the numerical keyboard,the amount shall get populated from right side of the decimal point (cents) to the left side of decimal point(Dollar). For e.g default value is $0.00 and when i put 1 then it should show $0.01 And when i put 2 it should show $0.12 and after that For 3 it should show $1.23 and so on to $99999.99. Please send the code me on ashishgore29@gmail.com. Thanks a lot for helping me. – AG29 Oct 12 '12 at 13:10
  • @Gill-: did u send me the solution i am still waiting. – AG29 Oct 15 '12 at 05:03
  • @Gill-: i got the answer gill. – AG29 Oct 16 '12 at 05:16