适配iPad的操作表sheet
在
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"上传文件"
message:@"请选择"
preferredStyle:UIAlertControllerStyleActionSheet];之后插入下面这段代码,就可以完成适配。
UIPopoverPresentationController *popover = alert.popoverPresentationController; // UIButton *button = (UIButton *)sender; if (popover) { popover.sourceRect = CGRectMake(self.view.center.x, self.view.frame.size.height, 0, 0); popover.sourceView = self.view; popover.permittedArrowDirections = UIPopoverArrowDirectionDown; }
最后,推出
[self presentViewController:alert animated:YES completion:nil];
成功。