ios - UIAlertController shown on BarButtonItem not centered properly -
i using following code show uialertcontroller on toolbarbuttonitem,
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]; the alertcontroller shown using code appears right sided not centered. want alertcontroller appear @ center position on toolbarbuttonitem.
try adding below code
 alertcontroller.popoverpresentationcontroller.sourceview = senderview; //your view  alertcontroller.popoverpresentationcontroller.sourcerect = senderview.bounds; //your view  alertcontroller.popoverpresentationcontroller.permittedarrowdirections = uipopoverarrowdirectionany; this fixed issue.
Comments
Post a Comment