views:

28

answers:

2

Hello,

I've placed an image in my UIView with IB.

How do I move this image around, resize it, etc programmatically? I cannot figure out how to reference it from my code.

Thanks a zillion.

+1  A: 

You need to make it an IBOutlet.

So in your viewController, or whatever you are loading from the nib, declare it like this:

IBOUtlet UIImageView *myImageView;

Also, in the actual nib, you must connect the File's Owner object to the UIImageView in your file by right-clicking File's owner and dragging the correct outlet name (in this case, myImageView) onto the correct UIImageView instance in your nib.

Now when you load one of the objects using the nib, myImageView will point to the initialized UIImageView, or whatever else you have.

Chris Cooper
if i have multiple images, how do i specify which one i want?
pureman
@pureman: see updated answer.
Chris Cooper
thanks a bunch. this worked like a charm
pureman
@pureman: Great to hear! =)
Chris Cooper
A: 

So if you create an UILabel in Inteface Builder, create an outlet like so in your .h file:

IBOutlet UIlabel* somelabel;

Then hook it up in Interface Builder and then you can access it like so:

somelabel.text = @"something";
ACBurk