gpt4 book ai didi

iphone - 为什么此NSLog代码将值打印为零?

转载 作者:行者123 更新时间:2023-12-01 17:28:15 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com