为什么此NSLog代码将值打印为零? [英] why does this NSLog code print zero's for the values?
本文介绍了为什么此NSLog代码将值打印为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么此Objective-C代码为值打印0,在调试器中,我看到它们具有非0值:
Why does this objective-c code print 0's for the values, where as in debugger I can see they have non-0 values:
代码
CGRect currFrame = label.frame;
currFrame.origin.y = currVertPos;
currFrame.origin.x = 0;
currFrame.size.height = expectedLabelSize.height;
currFrame.size.width = maxWidt h;
NSLog(@" currFrame dimensions:x/y/height/width = %d / %d / %d / %d", 0, currVertPos, expectedLabelSize.height, maxWidth);
打印的内容
currFrame dimensions:x/y/height/width = 0 / 0 / 0 / 0
推荐答案
因为您使用的是%d
,因此将数字格式化为整数.尝试改用%f
或%lf
:
Because you are using %d
hence formatting the number as integers. Try using %f
or %lf
instead:
NSLog(@" currFrame dimensions:x/y/height/width = %f / %f / %f / %f", 0, currVertPos, expectedLabelSize.height, maxWidth);
这篇关于为什么此NSLog代码将值打印为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文