在将若干份标为示意图时,我可以限制在标注之后的特性,例如%.03f
。 (点后显示3位数),但我如何删除点上的所有数字?
例如,我喜欢<代码>100.943到>>格式<943>
。
在将若干份标为示意图时,我可以限制在标注之后的特性,例如%.03f
。 (点后显示3位数),但我如何删除点上的所有数字?
例如,我喜欢<代码>100.943到>>格式<943>
。
I think the only way for you to do that would be to remove the number before the decimal point using math, or string manipulation after the fact, like componentsSeparatedByString:@"."
A simple math way of removing it would be:
float initialValue = 100.943f;
int beforeDecimal = (int)initialValue;
float afterDecimal = initialValue - beforeDecimal;
http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNumberFormatter_Class/"rel=“nofollow” 2011-11-23 18:36:59.138NSNumberFormatter
, 及其
float f = 123.456;
NSNumber * nF = [NSNumber numberWithFloat:f];
NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
[formatter setMaximumIntegerDigits:0];
NSLog(@"%@", [formatter stringFromNumber:nF]);
奥克·我猜想,我现在谈谈你的问题。
这里是你们将只摆脱扼杀的又一个解决办法。
例如:
NSString *floatAsString = @"123.456";
NSArray stringDivisions = [floatAsString componentsSeparatedByString:@"."];
Here what you will get in array is: 123 and 456 to separate string objects. Once you get two separate strings, you can play with them.
这是你们所需要的吗?
Simple way to do that, Here is an example,
首先,将你的胎体改为浮值。
浮动×=102.943;
in = x;
a. 浮动=x % y;
NSLog(@" x : %f y : %d ans : %f", x, y, ans);
因此,产出如下:
页: 1
y: 102
a 0.943000
希望是你们所需要的。
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...
I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I ...
I ve been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid ...
In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...
Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...
I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...
Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...