问题
I am trying to show an (AlertController) Action sheet. But I am getting this waning in console " <_UIPopoverBackgroundVisualEffectView 0x7fd65ef76ec0> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1. "
here is my code :-
extension GroupDataView {
func callDot (sender : UIButton)
{
let alert = UIAlertController(title: nil, message: nil,
preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Edit Group", style: .default , handler:{ (action)in
print("User click Edit Group")
}))
alert.addAction(UIAlertAction(title: "Create Folder", style: .default , handler:{ (action)in
print("User click Create Folder button")
}))
alert.addAction(UIAlertAction(title: "Delete Group", style: .destructive , handler:{ (action)in
print("User click Delete Group button")
}))
if let popoverController = alert.popoverPresentationController {
popoverController.sourceView = sender
popoverController.sourceRect = sender.bounds
self.present(alert, animated: true, completion: {
print("completion block")
})
}
else
{
self.present(alert, animated: true, completion: {
print("completion block")
})
}
}
}
I don't know why this warning is showing in console. ActionSheet is coming properly but how to remove that warning? Thanks
回答1:
iOS Bug
See answer by @Hardy on Apple Developer Forum: Warning message from UIPopover †
... seems to be a bug in iOS. But it does not seem to be critical. Though - I believe - that sometimes the area below the UIAlertController is not correctly drawn. I can see for a short period of time a black background flashing although the background of the underlying view is not black.
† Cached on Google here
回答2:
I had the same problem, and I resolved it by setting animated: false
in self.present
or/and self.dismiss
function. See the last comment in https://forums.developer.apple.com/thread/53677
回答3:
I realise this is an old question but I was just faced with the same issue and I found a workaround by delaying the presentation by 0.001 seconds so when you normally call this function I used this code for the delay
[self performSelector:@selector(viewBookmark:) withObject:bookmarkBarButton afterDelay:0.001];
Please excuse the OBJ-C but a similar delay in swift should have the same result of not displaying 2 views at the same time.
来源:https://stackoverflow.com/questions/41589946/uipopoverbackgroundvisualeffectview-is-being-asked-to-animate-its-opacity