title: Zbar scanner image box not repositioning right
body: <p>I have the following code to put an scanner box image around the scanning region for Zbar:</p>
  
  <pre><code>    -(UIView *)myOverlay
  {
  
      float width = [[UIScreen mainScreen] bounds].size.width;
      float height = [[UIScreen mainScreen] bounds].size.height;
      UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,width,height)];
  
      float imgX = 0;//width*0.12;
      float imgY = height*0.25;
      float imgW = width;
      float imgH = height*0.50;
  
      UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(imgX,imgY,imgW,imgH)];
      [FrameImg setImage:[UIImage imageNamed:@"scan_box_t.png"]];
      [FrameImg setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin];
      [view addSubview:FrameImg];
  
      //view.autoresizesSubviews = true;
  
      return view;
  }
  </code></pre>
  
  <p>Problem is, when I rotate my iPhone, the overlay view that this method generates doesn't move the image to the centre of the screen. The auto resizing mask I found from searching for a solution didn't appear to make a difference. The image is facing the right way up  - but is aligned to the left of the screen, not centre. What should I do?</p>
  
  <p>Edit: see below:</p>
  
  <p><a href="http://speedy.sh/dj8Sw/IMG-L.jpg" rel="nofollow">http://speedy.sh/dj8Sw/IMG-L.jpg</a></p>
  
  <p><a href="http://speedy.sh/EbqC4/IMG-P.jpg" rel="nofollow">http://speedy.sh/EbqC4/IMG-P.jpg</a></p>
  
  <p>IMG-L is the Landscape orientation, the other is portrait. The Portrait one is how it's supposed to look with the image starting at 25% width and height of the screen and the image itself have a width and height of 50% of the screen.</p>
  
  <p>Edit 2: Code that executes on rotation:</p>
  
  <pre><code>-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                  duration:(NSTimeInterval)duration
  {
      //reader.cameraOverlayView.bounds.size = [[UIScreen mainScreen] bounds].size;
      //reader.readerView willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
      //[reader.readerView setNeedsLayout];
      [reader.cameraOverlayView.FrameImg removeFromSuperview];
  
  }
  </code></pre>