We have a UISplitViewController and under condition X, we need to display a UIPopover from one of the UIBarButtonItem of the Master view.
Supposedly, in order to have the frame/layout correct, we do this code from the Master view controller's viewDidLoad event. Somehow the first time the UISplitViewController is shown, the frame of the Master is 1024x724 whereas we'd expect it to be 320x724. As a result, the call to [UIPopover presentFromBarButtonItem:] uses a wrong referential and since it's a right BarButtonItem, the popover appears all the way to the right of the screen (at about x = 980px)
If we delay the displaying by a split second (via a Timer/delay, sooo dirty) then it's all fine.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGRect masterViewFrame = self.view.frame;
NSLog(@"Master View Frame: %@", NSStringFromCGRect(masterViewFrame));
if (someCondition) {
[self showPopover:self.theBarButton];
}
}
The NSLog here shows 1024x724 @ 0x0
Thoughts?
-viewDidLoad
? Can you put it inviewWillAppear
orviewDidAppear
? – jrtc27