1. 程式人生 > >ActionSheet在iPad上的適配相容

ActionSheet在iPad上的適配相容

相容適配比較簡單,只需要在prenset之前加一個系統校驗:

if (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad) {
        if (alertController.popoverPresentationController != nil) {
            alertController.popoverPresentationController.sourceView = self.view;
            alertController.popoverPresentationController.sourceRect = CGRectMake(touchPoint.x, touchPoint.y, 1.0, 1.0);
        }
    }
    
    [self presentViewController:alertController animated:YES completion:nil];