views:

35

answers:

2

Well my title kind of says it all I guess ..( at least I hope)

I was hoping there was some sort of function that could take the real size of my picture

CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0, 210.0f);  // 234
      UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];

      [myImage setImage:[UIImage imageNamed:@"start.png"]];

And with CGRectMake which does something like this ..( imageViewHeight ,

CGFloat imageViewHeight = [myImage frame].size.height;

So that I could get the real size instead of having to define it like you can seen above.

+1  A: 

I don't really get what you're asking, but here's a shot:

If you have a UIImage, and you want to know its size, you can ask it for its -[UIImage size] property.

However, if you want to create a UIImageView that's the same size as a UIImage, then you can just use -[UIImageView initWithImage:], which will automatically set the frame of the UIImageView to correspond to the dimensions of the image.

If, however, you're just looking to change the dimensions of a currently existing view, there's really no easy way to do that without messing around with the view's frame. You could maybe apply an affine transform to scale it, but it's easier to manipulate the frame.

Dave DeLong
A: 

It looks like you're asking to add the image to the imageview without first creating a frame. If this is the case, you can do the following:

UIImageView *myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"start.png"]];
David Kanarek