2016-07-06 5 views
1

私は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]; 

、toolBarButtonItemにUIAlertControllerを表示するには、次のコードを使用しています。このコードを使用して示さalertControllerは、右中央にない味方表示されます。 alertControllerをtoolBarButtonItemの中央に正確に表示します。これは私の問題を修正したコード

alertController.popoverPresentationController.sourceView = senderView; //your view 
alertController.popoverPresentationController.sourceRect = senderView.bounds; //your view 
alertController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny; 

の下に追加

+1

barbuttonの代わりに 'alertController.popoverPresentationController.sourceRect'と' alertController.popoverPresentationController.sourceView'を試してみてください。 –

答えて

0

試してみます。

+0

ありがとうございました。 – Nikhil

+0

@Nikhilあなたは感謝としてupvoteすることができます;) –

関連する問題