LGAlertView icon indicating copy to clipboard operation
LGAlertView copied to clipboard

Black Screen problem when using with Swift

Open qasimsqm opened this issue 7 years ago • 6 comments

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()
}

qasimsqm avatar Aug 08 '17 08:08 qasimsqm

@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

cjndubisi avatar Sep 14 '17 12:09 cjndubisi

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

mickeyl avatar Sep 21 '17 07:09 mickeyl

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

NikKovIos avatar Nov 23 '17 17:11 NikKovIos

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

Friend-LGA avatar Mar 27 '18 08:03 Friend-LGA

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;
}

LyricApps avatar Nov 23 '18 09:11 LyricApps

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

kublaios avatar Dec 06 '18 23:12 kublaios