WYPopoverController
WYPopoverController copied to clipboard
popover in a modally presented viewcontroller
presenting a popover in a modal viewcontroller (presentPopoverAsDialogAnimated) does not work. any solutions/hints how to fix this?
Is your problem the same as #22? If yes, I'll try to address it tomorrow. If no, could you provide more detailed steps/some code to reproduce it? Thanks!
There is no error, the popover just not displayed.
I want to show the popover after tapping a button therefore i use following code:
`
func buttonTapped(sender: AnyObject){
self.setupBlurAndVibrancy()
//other stuff
}
func setupPopover() { let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark) blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView!.alpha = 0.7 blurEffectView!.frame = view.bounds self.view.addSubview(blurEffectView!)
let contentViewController = PopoverContentViewController(nibName: "PopoverContentViewController", bundle: nil)
self.popover = WYPopoverController(contentViewController: contentViewController)
self.popover!.setPopoverContentSize( CGSizeMake(200.0, 300.0), animated: true)
self.popover!.presentPopoverAsDialogAnimated(true)
contentViewController.popoverButton.setTitle("user.popover.login-now".localized, forState: .Normal)
contentViewController.popoverDismissButton.setTitle("user.popover.dont-login".localized, forState: .Normal)
contentViewController.popoverIcon.image = UIImage(named: "SuccessIcon")
contentViewController.popoverLabel.text = "user.popover.need-login".localized
contentViewController.popoverDismissButton.addTarget(self, action: "dismissPopover:", forControlEvents: UIControlEvents.TouchUpInside)
contentViewController.popoverButton.addTarget(self, action: "loginTapped:", forControlEvents: UIControlEvents.TouchUpInside)
self.popover?.delegate = self
}
`
i use this code in several parts in the project, sometimes it works and the popover will displayed. sometime only the blureffect appears.
as pagrit says, there are no errors. the popover just doesn't display. even the method "popoverControllerDidPresentPopover(popoverController: WYPopoverController!)" is called, but nothing is presented. i guess the view where the popover is attached to is not visible, or somewhere behind the modally presented viewController...
Thank you, I'll take a look. BTW, it will be really helpful if you share test project that reproduces this problem.
i made a little test project: https://nousguide.box.com/s/ydpgxw66tb703hd0dkjoxwyneayn23dk just download and unzip the file. open "PopoverTest.xcworkspace" and run the app. on the first screen/viewController, there is a working popover. when you hit the button (after dismissing the popover), another viewController is presented modally, (not) showing a popover in the viewDidAppear. the _inView.window property is nil in the case of modally presented viewController, but i don't know how to workaround... cheers!
@kampfgnu You have to set preferred content size for the content view controller before displaying it as modal popover.
Add contentViewController.preferredContentSize = CGSizeMake(200, 200)
after contentViewController
creation and your issue will be solved.
@pagrit ^
hmmm, did it work for you in the modal (magenta colored) viewController? i tried, but still no success...
I haven't checked it in the magenta colored view controller. Let me check
Ok, I can reproduce it.
are there any news? or hot fixed? or ideas why it doesn't work?
Added a fix for this - https://github.com/sammcewan/WYPopoverController/pull/87 Could anyone try it?