UIImage:大小的奇怪问题
我正在尝试从 Twitter 下载“profile_image_url”图像(.jpg)并将其显示在我的应用程序中。我正在尝试调整任何不符合我预期的图像的大小。在调试问题的过程中,我遇到了这种奇怪的行为。
代码:
NSLog(@"%d %d %d %d",48,image.size.width,image.size.height,48);
打印:
2010-02-09 13:26:43.925 MyApp[00000:0000] 48 0 1078460416 0
似乎高度和宽度打印不正确,也导致第二个“48”无法打印。这是怎么回事?
顺便说一句,UIImage 显示正常,如果我无法获取宽度和高度,我只是无法正确调整图像大小。
Im trying to download "profile_image_url" images (.jpg) from twitter and display them in my app. Im trying to resize any images that are not what I'm expecting them to be. In the process of debugging an issue, I ran into this strange behavior.
Code:
NSLog(@"%d %d %d %d",48,image.size.width,image.size.height,48);
Prints:
2010-02-09 13:26:43.925 MyApp[00000:0000] 48 0 1078460416 0
It appears that the height and width is not printing properly and also causes the second "48" not to print. What is going on here?
BTW, the UIImage displays fine I just cannot resize the image properly if i cannot get the width and height.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
%d 用于整数。使用 %f 打印浮点数(这就是 CGSize 成员)。
%d is for integers. Use %f for printing floats (which is what the CGSize members are).
image.size
是一个CGSize
,它将width
和height
存储为浮点数,而不是整数。因此,请在格式字符串中使用%f
。image.size
is aCGSize
which storeswidth
andheight
as floats, not ints. So use%f
in your format string instead.