title: Setting the position of an UIImageView in Objective-C
body: <p>I'm creating an iOS app that shows several items of a museum. Each item has a certain position on a map of the museum. Their coordinates are stored in an array. So far, so good.
  Depending on the item you choose, the position of this item should show up on a map.</p>
  
  <p>I've built the View in Xcode's Interface Builder. I've added an ImageView and set its position to 0 (x+y).</p>
  
  <p>I've added the ImageView as an outlet in my .h file:</p>
  
  <pre><code>@property (weak, nonatomic) IBOutlet UIImageView *myView;
  </code></pre>
  
  <p>Finally in the Views viewDidLoad()-Method I've tried to change the position of the Image View (containing a kind of "pointer-image") after hours of research (e.g <a href="https://stackoverflow.com/questions/8894335/how-to-set-image-position-programaticall-in-objective-c">here</a> or <a href="https://stackoverflow.com/questions/11611115/iphone-set-uiimage-position">here</a> or even <a href="https://stackoverflow.com/questions/8985334/uiimageview-doesnt-position-properly-on-ipad-always-on-0-0">here</a>) like this:</p>
  
  <pre><code>[self.myView setFrame:CGRectMake(xCoord, yCoord, self.myView.frame.size.width, self.myView.frame.size.height)];
  </code></pre>
  
  <p>xCoord and yCoord are float variables containing the coordinates of the item.
  I am NSLogging the frame's position before and after the setFrame-method and it tells me that the x and y position of the ImageView has changed. But on my Screen it still appears in the top left corner of the screen.</p>
  
  <p>I've already tried some different methods like this one:</p>
  
  <pre><code>CGRect needleOutletFrame = [self.myView frame];
  needleOutletFrame.origin.x = xCoord;
  needleOutletFrame.origin.y = xCoord;
  [self.myView setFrame:needleOutletFrame];
  </code></pre>
  
  <p>Didn't work either ...</p>
  
  <p>Has anyone got a hint for a solution to my problem?</p>
  
  <p>Cheers,
  Alex</p>
  
  <p>EDIT:</p>
  
  <p>I've deleted the UIImageView that I had created using Interface Builder and created an UIImageView in ViewWillAppear method by myself:</p>
  
  <pre><code>UIImageView *myView;
  myView = [[UIImageView alloc] init];
  [self.view addSubview:myView];
  myView.image = [UIImage imageNamed:@"ort_nadel_r.png"];
  [myView setFrame:CGRectMake(257, 90, 300, 300)];
  </code></pre>
  
  <p>I don't know why, but finally it works as I want it to!
  Thanks!</p>