Friend-LGA / LGAlertView

Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :)
MIT License
1.07k stars 212 forks source link

Black Screen problem when using with Swift #35

Open qasimsqm opened 7 years ago

qasimsqm commented 7 years ago

Following warning appears on console while running <UIVisualEffectView 0x7f8883c2bc70> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1. Once I show LGAlertView it turns screen into black screen. Following code is used

@IBAction func onClickEditProfile(sender: Any) {
        let lgaView: LGAlertView = LGAlertView.init(title: "", message: "What would you like to edit?", style: LGAlertViewStyle.actionSheet, buttonTitles: ["Edit Profile", "Edit Schedule"], cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, actionHandler: { (lgView: LGAlertView, index:UInt, title: String) in
            if(index == 0){
                self.navigationController?.pushViewController(EditProfileVC.editProfileVCLoad(), animated: true)
            }else{
                self.navigationController?.pushViewController(EditProfileVC.editProfileVCLoad(), animated: true)
            }

            } as? LGAlertViewActionHandler, cancelHandler: { (lgView: LGAlertView) in
            lgView.dismissAnimated()

        }) { (lgView: LGAlertView) in
            lgView.dismiss()
        }
        lgaView.showAnimated()
    }
cjndubisi commented 7 years ago

@qasimsqm Seems the window is getting hidden when you call show.You can fix this by immediately calling

UIApplication.shared.delegate?.window??.makeKeyAndVisible()
UIApplication.shared.delegate?.window??.isHidden = false

right after calling show

mickeyl commented 7 years ago

Same here w/ Objective-C. I did not have time to properly bisect yet, but a known-good version is ref ccb3cb494e4bd1873aefaccb3baf3c9a6c41309c.

NikKovIos commented 6 years ago

Seems that the same problem here https://github.com/Friend-LGA/LGAlertView/issues/34

Friend-LGA commented 6 years ago

Please, attach some demo project with the reproducible issue. If I have time, I will take a look.

LyricApps commented 5 years ago

The problem seems to be in LGAlertViewHelper.h, the app window is not necessarily the first window. In my case there are "hosted" windows which are created by AVPlayerViewController before the app window.

So you can try to replace :

+ (UIWindow *)appWindow {
    return [UIApplication sharedApplication].windows[0];
}

with :

+ (UIWindow *)appWindow {
    return [UIApplication sharedApplication].delegate.window;
}
kublaios commented 5 years ago

Please, attach some demo project with the reproducible issue. If I have time, I will take a look.

I don't use a storyboard and have this block in application:(UIApplication *)application didFinishLaunchingWithOptions:launchOptions::

self.window = UIWindow(frame: UIScreen.main.bounds)
let initialVC = InitialViewController.init()
window!.rootViewController = initialVC
window!.makeKeyAndVisible()

That's how I can reproduce the issue and this works for me as a workaround: https://github.com/Friend-LGA/LGAlertView/issues/35#issuecomment-329462957