开发者

Formatting UITextField not working?

开发者 https://www.devze.com 2023-03-18 17:12 出处:网络
Im trying to format my textfield for float values. Example: 0.00\" for some reason the code below works fine for other texfields, but not this one. Whats the deal? for my variables, i\'m codeing them

Im trying to format my textfield for float values. Example: 0.00" for some reason the code below works fine for other texfields, but not this one. Whats the deal? for my variables, i'm codeing them like this:

double var1 = [[myOtherTextField text] doubleValue];
double var2 ext...(same formatting as above, different textfield of course);
double var3 ext...(same formatting as above);

[myTextField开发者_JAVA百科 setText:[NSString stringWithFormat:@"%0.0f''", (var1 + var2 - var3)]];

The other two textfields are formatted the same way and are showing fine...why isn't this one? Thanks in advanced.


Try this.

double var1 = [[myOtherTextField text] doubleValue];
double var2 ext...(same formatting as above, different textfield of course);
double var3 ext...(same formatting as above);

[myTextField setText:[NSString stringWithFormat:@"%1.2f\"", (var1 + var2 - var3)]];
0

精彩评论

暂无评论...
验证码 换一张
取 消