简体   繁体   English

来自 frame.height 的 CGFloat 值

[英]CGFloat value from frame.height

I got stuck with something very stupid: cannot operate with CGFloat getting from view size.我遇到了一些非常愚蠢的事情:无法从视图大小获取 CGFloat 进行操作。 Could somebody help me and explain what am I doing wrong:有人可以帮助我并解释我做错了什么:

Here is the code:这是代码:

 CGFloat containedViewHeight = self.containedView_.frame.size.height;
 NSLog(@"========================   containedViewHeight  ================= %d", containedViewHeight);
 NSLog(@"========================   containedViewHeight1  ================= %d", self.containedView_.frame.size.height);

Here what I got:这是我得到的:

 ========================   containedViewHeight  ================= 1587588653

 ========================   containedViewHeight1  ================= 775

Value "775" looks good, but I cant save it to any variable.值“775”看起来不错,但我无法将其保存到任何变量中。 I also tried something like this:我也尝试过这样的事情:

int offset = containerHeight - (int)(self.containedView_.frame.size.height);

(int)(self.containedView_.frame.size.height) is always equal 0 (int)(self.containedView_.frame.size.height) 总是等于 0

Please give me a hint of what is wrong...请给我一个提示什么是错的......

*** If I use %f as inside log than I got: *** 如果我使用 %f 作为内部日志,我得到:

========================   containedViewHeight  ================= 0.000000
=======================   containedViewHeight1  ================= 0.000000

You're passing %d to NSLog's string format.您将%d传递给 NSLog 的字符串格式。 That interprets containedViewHeight as an integer.这将 containsViewHeight 解释为containedViewHeight You want %f .你想要%f

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM