我使用此代码试图将漂浮转换为int,然后用它的UILabel文本:正确使用将float转换为int来获取百分比?
[progLabel setText:[NSString stringWithFormat:@"Deck Progress %i%%",progBar.progress*100]];
,我已经试过这样:
[progLabel setText:[NSString stringWithFormat:@"Deck Progress %i%%",(int)progBar.progress*100]];
显示的文本是总是“0%”。
我也试过这其中的工作原理:
int pval=progBar.progress*100;
[progLabel setText:[NSString stringWithFormat:@"Deck Progress %i%%",pval]];
我已经试过%F %%,但是这给了我太多的数字 - 我试图让只有0-100,没有小数位。
我在做什么错?
尝试'(int)(progBar.progress * 100)' – 2012-04-02 18:54:39