我使用以下代碼來顯示UIAlertController上的toolBarButtonItem,使用該代碼所示UIAlertController不居中正確
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Delete Selected Accounts" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[Utility showAlertWithTitle:nil message:DELETE_ACCOUNT delegate:self tag:1 buttons:@[@"Cancel", @"Delete"]];
}]];
alertController.popoverPresentationController.barButtonItem = self.moreButtonItem;
[self presentViewController:alertController animated:YES completion:nil];
的alertController出現右雙面不居中。我希望alertController恰好位於toolBarButtonItem的中心位置。
嘗試使用'alertController.popoverPresentationController.sourceRect'和'alertController.popoverPresentationController.sourceView'來代替barbutton –