Gre*_*reg 1 iphone objective-c string-formatting nslog ios
为什么这个objective-c代码为值打印0,而在调试器中我可以看到它们具有非0值:
码
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);
Run Code Online (Sandbox Code Playgroud)
什么是印刷品
currFrame dimensions:x/y/height/width = 0 / 0 / 0 / 0
Run Code Online (Sandbox Code Playgroud)
所有这些值都有CGFloat类型,但您尝试将它们打印为ints.只需更换%d用%f.
PS苹果开发者不得不CGRect偶尔打印,所以他们提出了一些方便的方法.试试NSLog(@"currFrame dimensions: %@", NSStringFromCGRect(currFrame)).
| 归档时间: |
|
| 查看次数: |
1790 次 |
| 最近记录: |