I've got a UIPopoverController which I've been using for awhile. I'm updating my code for iOS 7 now and when I resize the popover it suddenly moves across the screen which makes for a very bad user experience.
When I'm in portrait orientation, it doesn't happen. I tap to open the popover, then I tap the button which causes the popover to expand and everything is fine. However, if I switch to Landscape orientation and do the same thing, when I tap the button to expand the popover, then it slides over to another location.
Here is a video showing what I'm talking about: https://vimeo.com/75632364
This the code that runs when the user taps the button that causes the resize of the popover:
- (IBAction) touchedButtonPayDownLoan:(id)sender {
UIView *payOffView = nil;
if ([self.liability isBankLoan]) {
payOffView = self.viewPayoffBank;
} else {
payOffView = self.viewPayoffOther;
}
CGRect loanFrame = payOffView.frame;
loanFrame.origin.y = self.toolbar.frame.origin.y;
payOffView.frame = loanFrame;
[self.view addSubview:payOffView];
[self.view bringSubviewToFront:self.toolbar];
[UIView beginAnimations:@"Show Payoff View" context:nil];
NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items removeLastObject];
[items addObject:self.barButtonFinish];
self.toolbar.items = items;
// -------- RELEVANT BITS HERE ---------
CGRect frame = self.view.frame;
frame.size.height += payOffView.frame.size.height;
self.view.frame = frame;
self.preferredContentSize = frame.size;
// -------- RELEVANT BITS HERE ---------
[UIView commitAnimations];
}
I don't want the popover to jump positions, because that will annoy the user. Any ideas?