0

I simply want to get the frame coordinates of a UIView iVar contained within a UIViewController. For example, if but0 is the iVar, and this fcn is called from the ViewController ViewDidLoad method:

CGFloat x = self.but0.frame.origin.x;

This always returns 0, no matter where the button is placed with Interface Builder. What am i missing?

4

2 に答える 2

1

Edit: Spectravideo328 is right, you should use viewWillAppear or viewDidAppear.

You could try to convert the frame of the from the UIView.
Something like:

CGRect frame = [self.view convertRect:btn.frame fromView:tableView.frame];

于 2013-02-15T21:47:31.887 に答える
0

ViewDidLoad loads the view but the frame/bounds have not been set. ViewDidAppear is guaranteed to happen after the frame/bounds have been set. Use that method.

于 2013-02-15T21:47:22.770 に答える