Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
Fix setting permitted arrow directions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Chupin committed Feb 3, 2017
1 parent 7e962d3 commit 2664bb7
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions PSTAlertController/PSTAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,18 @@ - (void)showWithSender:(id)sender arrowDirection:(UIPopoverArrowDirection)arrowD
}

// optimize arrow positioning for up and down.
UIPopoverPresentationController *popover = controller.popoverPresentationController;
popover.permittedArrowDirections = arrowDirection;
switch (arrowDirection) {
case UIPopoverArrowDirectionDown:
popoverPresentation.sourceRect = CGRectMake(r.origin.x + r.size.width/2.f, r.origin.y, 1.f, 1.f);
break;
case UIPopoverArrowDirectionUp:
popoverPresentation.sourceRect = CGRectMake(r.origin.x + r.size.width/2.f, r.origin.y + r.size.height, 1.f, 1.f);
break;
// Left and right is too buggy.
default:
break;
}
popoverPresentation.permittedArrowDirections = arrowDirection;
switch (arrowDirection) {
case UIPopoverArrowDirectionDown:
popoverPresentation.sourceRect = CGRectMake(r.origin.x + r.size.width/2.f, r.origin.y, 1.f, 1.f);
break;
case UIPopoverArrowDirectionUp:
popoverPresentation.sourceRect = CGRectMake(r.origin.x + r.size.width/2.f, r.origin.y + r.size.height, 1.f, 1.f);
break;
// Left and right is too buggy.
default:
break;
}
}

// Hook up dismiss blocks.
Expand Down

0 comments on commit 2664bb7

Please sign in to comment.