简体   繁体   中英

iOS 6 UIView properties yield 0

I'm trying to do something very, very simple and it doesn't work; so it seems I'm missing something fundamental. I have a single-view application. There's an image in the center. I'd like to move it with user touch. The problem is, I cannot retrieve the coordinate values from the image. Here's what I do:

I have the UIImageView in the storyboard and it's centered with the image file loaded.

I make an outlet to the image view in my ViewController's header file:

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

And naturally, it's connected to the imageView in the storyboard.

In my ViewController's implementation file, in view did load I have this:

[super viewDidLoad];
CGPoint center = self.imageView.center;
NSLog(@"center: %f, %f", center.x, center.y);

The results I have in the console are, unfortunately, both 0. The image view is owned by the main UIView of my ViewController. There seems to be a very, very fundamental problem but I just can't figure it out. Thanks for all the help!

您是否通过ctrl从情节提要中拖动到代码中将情节提要中的imageview从情节提要连接到代码中的插座?

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