Resolved problems to put an image at the right spot


hi guys

i'm using auto layout. put image inside uiimageview. imageview positioned using auto layout. long using natural image fine. of course when no image provided want add plus sign. plus sign gets stretched because imageview using scaletofill. decided put code inside viewdidlayoutsubviews():

code:
 self.wifeimageview.frame = cgrectmake(self.wifeimageview.frame.origin.x + self.wifeimageview.frame.height * 2/3, self.wifeimageview.frame.origin.y + self.wifeimageview.frame.height * 1/3 , self.wifeimageview.frame.height * 2/3, self.wifeimageview.frame.height * 2/3)              }                self.wifeimageview.contentmode = uiviewcontentmode.scaletofill              self.wifeimageview.clipstobounds = true              self.wifeimageview.image = uiimage(named: "plus") 
this code works fine. till rotate device. it's stretched on again. if use same technique inside didrotatefrominterfaceorientation(frominterfaceorientation: uiinterfaceorientation) imageview keeps getting smaller , shifting. got suggestion how solve rotating part? thanks!
 

if you're using auto layout don't set frame in code. constraints control frame.

recommend tutorials on raywenderlich.com learn auto layout.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

OS X El Capitan on Unsupported Macs

[SOLVED] SFOTT usb key not bootable Mavericks

Fernando Torres: One of the all-time greats?