为什么此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);

打印什么
currFrame dimensions:x/y/height/width = 0 / 0 / 0 / 0

最佳答案

因为您使用的是%d,所以将数字格式化为整数。尝试改用%f%lf:

NSLog(@"  currFrame dimensions:x/y/height/width = %f / %f / %f / %f", 0, currVertPos, expectedLabelSize.height, maxWidth);

关于iphone - 为什么此NSLog代码将值打印为零?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5254239/

10-13 04:36