pmusolino / PMAlertController

PMAlertController is a great and customizable alert that can substitute UIAlertController
MIT License
2.53k stars 187 forks source link

Blackscreen when goes back to alert controller using tab bar ? #31

Closed fadylateef closed 7 years ago

fadylateef commented 7 years ago

I have 3 tab bar items with 3 different view controller. And I use PMAlertController for the first tab item, it works great but whenever I select another tab item and go back to the first one it gives black screen.

I think it may relate to super views and order of views .

Thanks in advance for the great library.

screen shot 2016-12-12 at 4 08 32 pm screen shot 2016-12-12 at 4 08 47 pm screen shot 2016-12-12 at 4 08 40 pm
pmusolino commented 7 years ago

Hi @fadylateef. Can you post the code here?

Thanks -Paolo

fadylateef commented 7 years ago

I'm using an action when the red close button tapped . Here's the code

import UIKit

class RecentlySearchedViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
@IBAction func deleteTapped(_ sender: Any) {
        let alert = PMAlertController(title: "Delete History", description: "Do you really want to delete recent searches ?!", image: nil, style: .alert)
        alert.addAction(PMAlertAction(title: "Yes", style: .default, action: {kaka in
        self.deleteRecents()
        }))
        alert.addAction(PMAlertAction(title: "No", style: .cancel, action: nil))
        self.present(alert, animated: true, completion: nil)
    }
}
pmusolino commented 7 years ago

Usually is not possibile to tap on another tab with PMAlertController showed.

I made a test project, and i don't have this type of error. Which controller is presenting PMAlertController? PMTabBarWithAlert.zip

pmusolino commented 7 years ago

Do you have some news about that?

fadylateef commented 7 years ago

I'm afraid , the same problem is standing. Maybe I've used the alert controller in wrong order of views hierarchy .

Thanks for due care .

On Thu, Dec 15, 2016 at 12:03 PM, Paolo Musolino notifications@github.com wrote:

Do you have some news about that?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Codeido/PMAlertController/issues/31#issuecomment-267288498, or mute the thread https://github.com/notifications/unsubscribe-auth/AQvIgT6NV-NxniENtQPU8xZG1FBNAbsiks5rIRBVgaJpZM4LKhus .

mn288 commented 7 years ago

I have the same problem and it is not because of the view hierarchy. I was using PMAlertController from a subclass which then I call it from a the view in the tabbar. I tried removing the subclass and directly calling PMAlertController, I can still press on any tabbar Item and sometimes the screen is black. It was not doing the same behavior prior swift 3. I am not sure what the problem is for me.

pmusolino commented 7 years ago

@mn288 if you try to use UIAlertController, do you have the same problem?

fadylateef commented 7 years ago

Tried on another project and it's working fine. Using Xcode 8.2 beta and iOS 10.2.

attheodo commented 7 years ago

I have the same issue while presenting from a subclass

akring commented 6 years ago

Same problem here, I have to use this via:

guard let root = UIApplication.shared.keyWindow?.rootViewController else { return }
root.present(alert, animated: true, completion: nil)
Burakpusat commented 5 years ago

I was having the same issue. I was able to overcome the problem by the help of @akring above.