Skip to content

Commit

Permalink
Center actionsheet on iPad #49 (take 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 2, 2017
1 parent e91910d commit b7773b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Android code: mostly [Brill Papping](https://github.com/bpappin)


## 6. Change history
* 2.3.2 Default iPad popup is now in the center (was in the top left corner)
* 2.3.3 Default iPad popup is now in the center (was in the top left corner)
* 2.3.1 Added `subtitle` (iOS) and `destructiveButtonLast` preferences. Also, iOS now uses the newer `UIAlertController` instead of `UIActionSheet`.
* 2.2.2 OK, 2.2.1 has issues with Russian and the like, so reverted. Just add `<meta charset="utf-8" />` to your html file.
* 2.2.1 Encoding of diacritical characters fixed on iOS, so you can now use `Español` as a title or button label.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-actionsheet",
"version": "2.3.2",
"version": "2.3.3",
"description": "Show a sheet of options the user can choose from.",
"cordova": {
"id": "cordova-plugin-actionsheet",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin
xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-actionsheet"
version="2.3.2">
version="2.3.3">

<name>ActionSheet</name>

Expand Down
8 changes: 6 additions & 2 deletions src/ios/ActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ - (void)show:(CDVInvokedUrlCommand *)command
UIPopoverPresentationController *popPresenter = [self.alertController popoverPresentationController];
popPresenter.sourceView = self.webView.superview;
if (position == nil) {
NSLog(@"Because the 'postion' param is not set, on iPad the popup is shown in the top left corner.");
NSLog(@"Because the 'postion' param is not set, on iPad the popup is shown in the center.");
[popPresenter setPermittedArrowDirections:0];
popPresenter.sourceView = self.webView.superview;
popPresenter.sourceRect = CGRectMake(CGRectGetMidX(self.webView.bounds), CGRectGetMidY(self.webView.bounds), 0, 0);
} else {
popPresenter.sourceRect = [self getPopupRectFromIPadPopupCoordinates:position];
}
popPresenter.sourceRect = [self getPopupRectFromIPadPopupCoordinates:(position != nil ? position : @[@40, @20])];
}
[self.viewController presentViewController:self.alertController animated:YES completion:nil];
});
Expand Down

0 comments on commit b7773b9

Please sign in to comment.