Getting Alert for UIPopoverBackgroundVisualEffectView

I present the UIActionSheet in my view, and one of the action bar buttons is another action sheet. When I present the second plan of action on the iPad, I get this warning in the logs:

UIPopoverBackgroundVisualEffectView is asked to animate its opacity. This will cause an effect until the opacity returns to 1.

This is my code:

 UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Option"] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Sort", nil]; actionSheet.tag = 1; [actionSheet showInView:self.view]; 

And in the delegate:

 -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { [self showSortAction]; } -(void)showSortAction { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Sort By" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"AZ", @"ZA", @"Newer to older", @"Older to newer", nil]; actionSheet.tag = 2; [actionSheet showInView:self.view]; } 
+5
source share
2 answers

My guess is that presenting the second action sheet causes a change in the transparency of the first action, causing the warning you see. Instead of calling -showSortAction from -actionSheet:clickedButtonAtIndex: call it from -actionSheet:didDismissWithButtonIndex: This gives the first action screen enough time to disappear from the screen before the second starts the animation. (See UIActionSheetDelegate Documentation - in particular, the long text for selected and done-rejected methods.)

However, note that the UIActionSheet Documentation says it is deprecated with iOS 8. If you are not using programming on iOS 7 or later, consider switching to UIAlertController as soon as possible.
+4
source

@Tim is true above.

You should no longer use the deprecated UIActionSheet. His decision to use actionSheet:didDismissWithButtonIndex: might work earlier, but according to fooobar.com/questions/1263664 / ... it will not work anymore since Apple switched to UIAlertController .

You really have to switch your code to UIAlertController instead of the old method in order to fix this problem.

+2
source

Source: https://habr.com/ru/post/1263662/


All Articles