BDBPopupViewController
BDBPopupViewController copied to clipboard
Presenting over a view controller with non-FullScreen modal presentation style doesn't work
For example, I changed your demo to allow opening another version of the main view controller with FormSheet presentation style, run it on iPod. Hit the nav bar button to open the form view controller and press the button, the popup is opened behind the form view controller's view instead of over top of it.
@interface MainViewController ()
@property (nonatomic, assign, getter=isForm) BOOL form;
@end
@interface FormNavigationViewController : UINavigationController
@end
#pragma mark -
@implementation MainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = NSLocalizedString(@"Popup Demo", nil);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIBarButtonItem *barButton;
if (!self.form)
barButton = [[UIBarButtonItem alloc] initWithTitle:@"Form" style:UIBarButtonItemStylePlain target:self action:@selector(openForm)];
else
barButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(dismissForm)];
barButton.tintColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem = barButton;
}
}
- (IBAction)showInfo:(UIButton *)sender
{
[self bdb_presentPopupViewController:[AboutViewController new]
withAnimation:BDBPopupViewShowAnimationZoomIn
completion:nil];
}
- (void)openForm
{
MainViewController *containedViewController = [MainViewController new];
containedViewController.form = YES;
UIViewController *form = [[FormNavigationViewController alloc] initWithRootViewController:containedViewController];
[self presentViewController:form animated:YES completion:nil];
}
- (void)dismissForm
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
#pragma mark -
@implementation FormNavigationViewController
- (UIModalPresentationStyle)modalPresentationStyle
{
return UIModalPresentationFormSheet;
}
@end```