How can I fix the “UIPopoverController is deprecated” warning?

后端 未结 4 704
一向
一向 2020-12-01 01:19

I am using this code:

mediaLibraryPopover = [[UIPopoverController alloc] 
                        initWithContentViewController:avc];
[self.mediaLibraryPopov         


        
4条回答
  •  时光说笑
    2020-12-01 02:08

    If wanted directly from Button Action then this code can be used

    SecondViewController *destinationViewController = (SecondViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"second"];
    destinationViewController.modalPresentationStyle = UIModalPresentationPopover;
    destinationViewController.popoverPresentationController.sourceView = self.customButton;
    
    // Set the correct sourceRect given the sender's bounds
    destinationViewController.popoverPresentationController.sourceRect = ((UIView *)sender).bounds;
    [self presentViewController:destinationViewController animated:YES completion:nil];
    

提交回复
热议问题