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