Browse Source

fix deprecate

Marino Faggiana 6 years ago
parent
commit
ae3a7b9f61
2 changed files with 12 additions and 19 deletions
  1. 7 9
      iOSClient/Settings/CCSettings.m
  2. 5 10
      iOSClient/Share/CCShareOC.m

+ 7 - 9
iOSClient/Settings/CCSettings.m

@@ -262,15 +262,13 @@
                 [self reloadForm];
             }]];
             
-            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
-                // iPhone
-                [self presentViewController:alertController animated:YES completion:nil];
-            }else {
-                // iPad
-                // Change Rect to position Popover
-                UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
-                [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:rowDescriptor]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
-            }
+            
+            alertController.popoverPresentationController.sourceView = self.view;
+            NSIndexPath *indexPath = [self.form indexPathOfFormRow:rowDescriptor];
+            CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
+            alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
+            
+            [self presentViewController:alertController animated:YES completion:nil];
             
         } else {
             

+ 5 - 10
iOSClient/Share/CCShareOC.m

@@ -292,17 +292,12 @@
     
     UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
     
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
-        [self presentViewController:activityController animated:YES completion:nil];
+    activityController.popoverPresentationController.sourceView = self.view;
+    NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
+    CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
+    activityController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
     
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
-        
-        UIPopoverController *popup;
-        
-        popup = [[UIPopoverController alloc] initWithContentViewController:activityController];
-        [popup presentPopoverFromRect:CGRectMake(120, 100, 200, 400) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
-    }
-
+    [self presentViewController:activityController animated:YES completion:nil];
 }
 
 - (void)shareUserButton:(XLFormRowDescriptor *)rowDescriptor