iosobjective-ccgfloat

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

Solution

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