0
我试图显示一个UIAlertController与一些操作按钮。它在iPhone上运行良好,因为它从设备底部弹出。我有一个ipad的问题,UIAlertController没有正确居中。它显示了一点偏右。我可以通过减去150f来从x坐标中减去。有没有办法让它居中?UIAlertController - iOS 8 - iPad - 没有正确居中
UIAlertController * view= [UIAlertController
alertControllerWithTitle:@"My Title"
message:@"Select your Choice"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Do some thing here
[view dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[view dismissViewControllerAnimated:YES completion:nil];
}];
[view addAction:ok];
[view addAction:cancel];
view.popoverPresentationController.sourceView = self.view;
view.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0, 0.0, 0.0);
[self presentViewController: view animated:YES completion:nil];
什么是'self.view.frame'相对于'[UIScreen mainScreen] .bounds'?它是否完美居中? – Stuart