【发布时间】:2015-10-06 00:11:13
【问题描述】:
我正在尝试显示带有一些操作按钮的 UIAlertController。它在 iPhone 上运行良好,因为它从设备底部弹出。我的 ipad 有问题,UIAlertController 没有正确居中。它显示在右侧。我可以通过减去 150f 来从 x 坐标中减去。有没有办法让它居中?
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];
【问题讨论】:
-
相对于
[UIScreen mainScreen].bounds,self.view.frame是什么?是否完全居中?
标签: ios ipad uialertcontroller