I am programmatically creating a UIView which will eventually become a help speech bubble for my universal app but I am having difficulty in getting the UIView to support device rotations. When my view is created it looks great, just how I want it but when I rotate the device then my UIView popover expands to fill the entire screen which is not what I want.
I am using iOS 6 with Auto Layout for the other storyboard controls if that helps.
Could somebody please explain why iOS resizes my popover to full screen on device rotation?
I also looked at adding some constraints to it but thought that was more for the sub layers rather than the popover view itself.
The code I am using is:
customView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
customView.layer.cornerRadius = 15;
customView.layer.borderWidth = 1.5f;
customView.backgroundColor = [UIColor blackColor];
[customView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self.tableView.superview addSubview:customView];
[customView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Flexiblewidth/height autoresizing mask resizes your UIView when the parent view changes. When the view is rotated, your superview's frame is changed and the view will change width and height proportionally. If you want the same size, remove that line, if you want the same padding around your view use
[customView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin];