ios - SDK7 格式编号

标签 ios objective-c

需要格式化数字四位数字,无小数,包括左边的0,例如0012. 我在 Xcode for iPhone 上编写这段代码。

if (Tipo.selectedSegmentIndex == 2 ) { 
   float a = [N1.text floatValue];  float b = [N2.text floatValue];  
   float c = a*b;  
   R.text = [[NSString alloc] initWithFormat:@"%.0f",c];  
}

最佳答案

尝试这样的事情,如果有帮助请告诉我

 self.yourTimeHere.text = [NSString stringWithFormat:@"%d.%d", (int)hours, (int)minutes];

关于ios - SDK7 格式编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19397050/

相关文章:

ios - 如何更改永远运行的 SKAction

ios - SWIFT map View MKRoutePolyline interiorPolygons : unrecognized selector sent to instance 0x14ed4b4d0

ios - NSInternalInconsistencyException 错误

objective-c - 在 NSMutableArray 方法中,removeObject : vs removeObjectIdenticalTo:

javascript - 可以检测到选择元素的 native UI 覆盖吗?

iphone - 当应用商店中有新版本时,通过代码检查和更新应用程序

ios - 如何以编程方式替换 UITabBarController 的 UITabBar

ios - UITextField 光标和键盘问题

iphone - 在 iPhone 上保存数据的最佳方式

objective-c - 如何设置先前创建的 NSMutableString 的文本?