views:

313

answers:

3

hi all, i am new to iPhone. i want to get the height of a image. so i can set the frame of UIImageview accordingly. Please suggest how can i get the original size(width and height) of image.

+1  A: 

You can try to check

[[UIImage imageNamed:@"myImage.png"] size].height;
[[UIImage imageNamed:@"myImage.png"] size].width;
Morion
Ok, 3 seconds faster than me, you win. :)
Pascal
oh sorry. I wrote it from PC, not mac) so the only aim was to show a principle) anyway, thanks for correction.
Morion
+3  A: 

Well, if you have the image as UIImage, then you want to take a look at the size property:

CGFloat width = myImage.size.width;
CGFloat height = myImage.size.height;
Pascal
+1  A: 

Maybe this also helping you:

UIImage *image = [ UIImage imageNamed: @"image.png" ];
imageView.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
zZzZ