Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

popover in a modally presented viewcontroller #85

Open
kampfgnu opened this issue Aug 29, 2016 · 11 comments
Open

popover in a modally presented viewcontroller #85

kampfgnu opened this issue Aug 29, 2016 · 11 comments
Labels
Milestone

Comments

@kampfgnu
Copy link

presenting a popover in a modal viewcontroller (presentPopoverAsDialogAnimated) does not work.
any solutions/hints how to fix this?

@vitalys
Copy link
Collaborator

vitalys commented Aug 29, 2016

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!

@pagrit
Copy link

pagrit commented Aug 30, 2016

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.

@kampfgnu
Copy link
Author

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...

@vitalys
Copy link
Collaborator

vitalys commented Aug 30, 2016

Thank you, I'll take a look. BTW, it will be really helpful if you share test project that reproduces this problem.

@kampfgnu
Copy link
Author

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!

@vitalys
Copy link
Collaborator

vitalys commented Sep 2, 2016

@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 ^

@kampfgnu
Copy link
Author

kampfgnu commented Sep 2, 2016

hmmm, did it work for you in the modal (magenta colored) viewController? i tried, but still no success...

@vitalys
Copy link
Collaborator

vitalys commented Sep 2, 2016

I haven't checked it in the magenta colored view controller. Let me check

@vitalys
Copy link
Collaborator

vitalys commented Sep 2, 2016

Ok, I can reproduce it.

@vitalys vitalys added this to the 0.4.0 milestone Sep 2, 2016
@pagrit
Copy link

pagrit commented Oct 27, 2016

are there any news? or hot fixed? or ideas why it doesn't work?

@algrid
Copy link

algrid commented Nov 19, 2016

Added a fix for this - #87
Could anyone try it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants