Reputation: 113
I have a login view which I want to display in popover. I am doing this from code as below:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[NSString stringWithFormat:@"MainStoryboard_%@", isIPAD ? @"iPad" : @"iPhone"] bundle:NULL];
UIViewController *navCtrl = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navCtrl];
popover = popover;
popover.delegate = self;
popover.popoverBackgroundViewClass = [PopoverBackground class];
self.popover = popover;
[self.popover presentPopoverFromRect:((UIButton *)sender).bounds
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown
animated:YES];
But the popover never shows. But the weird thing is viewdidload and viewwillappear for loginview are called. And on again clicking on the view calls the popover delegate method didDismissPopover.
Though it works fine when presented from a popover segue.
I do not want to create a segue because login might be called from different locations and I want to keep this code separate.
Has anyone before faced such issue.
Upvotes: 0
Views: 1743
Reputation: 113
Solved it!!
Turned out I was giving the arrow direction as UIPopoverArrowDirectionDown
and the rect to show was not proper. Changed the rect to (100, 500, 10, 10)
, and voila! Everything is perfect.
Upvotes: 3