简体   繁体   中英

CGFloat value from frame.height

I got stuck with something very stupid: cannot operate with CGFloat getting from view size. 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. 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

Please give me a hint of what is wrong...

*** If I use %f as inside log than I got:

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

You're passing %d to NSLog's string format. That interprets containedViewHeight as an integer. You want %f .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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