0

I'm trying to show an UIImageView with images on my iPhone 4, but this doesn't appear completely. The bottom part is hidden...this is the result:

enter image description here

I have tryed with 0 constraints on left, right, top and bottom margins but no effect... Also adding width to 320 but the height is allways 568px (4 inch screen height )

Is not an image aspect problem. I'm using Aspect FIll for this case and works good, but the imageView height is always 568px. If I resize manually the heigth to 480px the image is OK.

Thanks a lot! I don't know what can I do...

pekpon
  • 761
  • 1
  • 10
  • 24

5 Answers5

3

try to use this,

[imgView setContentMode:UIViewContentModeScaleToFill]
Saheb Singh
  • 555
  • 4
  • 18
  • Is not a Content Mode problem...the frame is allways 568px, this is the problem. If I resize the ImageView to 480px, the image is showed correctly – pekpon Apr 23 '14 at 06:25
0

You need to set the aspect ratio of the image.

Hope this helps.

Community
  • 1
  • 1
user2071152
  • 1,161
  • 1
  • 11
  • 25
  • Is not a Content Mode problem...the frame is allways 568px, this is the problem. If I resize the ImageView to 480px, the image is showed correctly – pekpon Apr 23 '14 at 06:26
  • Then you need to use autolayout option to adjust the size automatically to fit 4 inch and a 3.5 inch screen. – user2071152 Apr 23 '14 at 06:28
  • How? I have tryed with constraints (right, left, top ad bottom) but without effect... – pekpon Apr 23 '14 at 06:32
  • From Menu Option 'Editior\PIN' Top Space to Superview, Leading Space to Superview Try using these options. – user2071152 Apr 23 '14 at 06:41
  • In XCode storyboard you can check the size of ImageView for both 3.5 inch and 4 inch screen. You can be sure whether ImageView is having 568 px. – user2071152 Apr 23 '14 at 07:06
0

Don't set frame programatically , if you set 568px height, it will take for both 4inch and 3.5. just drag and drop the image view in to storyboard view. from Xcode5 autoLayout is there. Adjust autolayout. autolayout will automatically fit the frames.

AutoLayout Apple Library

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
  • I'm using storyboard drag and drop! At the beginning all worked fine, and the ImageView resizes fine changing between 4 and 3,5, making the work good. But now when I try to change between screens sizes, the imageView is allways 568px... – pekpon Apr 23 '14 at 06:28
  • use autolayout, check out apple documentation https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/AutoLayoutbyExample/AutoLayoutbyExample.html – Vineesh TP Apr 23 '14 at 06:37
0

Delete the constraint which forces the height to 568px. And Add constraint for left, top, right, bottom, margins with value 0.

Rukshan
  • 7,902
  • 6
  • 43
  • 61
0

you set autosizing

you select image then set like below imgae

[imgView setContentMode:UIViewContentModeScaleToFill]

it working iphone 5 or 4

enter image description here

kirti Chavda
  • 3,029
  • 2
  • 17
  • 29