Browse Source

new version Lib XLForm compatible XCode 9

Marino Faggiana 7 years ago
parent
commit
cced4ba094

+ 10 - 12
iOSClient/Library/XLForm/XL/Cell/XLFormImageCell.m

@@ -29,7 +29,6 @@
 
 @interface XLFormImageCell() <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
 {
-    UIPopoverController *popoverController;
     UIImagePickerController *imagePickerController;
     UIAlertController *alertController;
 }
@@ -113,16 +112,15 @@
     imagePickerController.sourceType = source;
     
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
-        popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
-        [popoverController presentPopoverFromRect: self.contentView.frame
-                                           inView: self.formViewController.view
-                         permittedArrowDirections: UIPopoverArrowDirectionAny
-                                         animated: YES];
-    } else {
-        [self.formViewController presentViewController: imagePickerController
-                                              animated: YES
-                                            completion: nil];
+        imagePickerController.modalPresentationStyle = UIModalPresentationPopover;
+        imagePickerController.popoverPresentationController.sourceRect = self.contentView.frame;
+        imagePickerController.popoverPresentationController.sourceView = self.formViewController.view;
+        imagePickerController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
     }
+    
+    [self.formViewController presentViewController: imagePickerController
+                                          animated: YES
+                                        completion: nil];
 }
 
 #pragma mark -  UIImagePickerControllerDelegate
@@ -138,8 +136,8 @@
     }
     
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
-        if (popoverController && popoverController.isPopoverVisible) {
-            [popoverController dismissPopoverAnimated: YES];
+        if (self.formViewController.presentedViewController && self.formViewController.presentedViewController.modalPresentationStyle == UIModalPresentationPopover) {
+            [self.formViewController dismissViewControllerAnimated:YES completion:nil];
         }
     } else {
         [self.formViewController dismissViewControllerAnimated: YES completion: nil];

+ 16 - 73
iOSClient/Library/XLForm/XL/Cell/XLFormLeftRightSelectorCell.m

@@ -28,11 +28,6 @@
 #import "NSObject+XLFormAdditions.h"
 #import "XLFormLeftRightSelectorCell.h"
 
-@interface XLFormLeftRightSelectorCell() <UIActionSheetDelegate>
-
-@end
-
-
 @implementation XLFormLeftRightSelectorCell
 {
     UITextField * _constraintTextField;
@@ -195,76 +190,24 @@
 
 -(void)leftButtonPressed:(UIButton *)leftButton
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
-    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                              delegate:self cancelButtonTitle:nil
-                                                destructiveButtonTitle:nil
-                                                     otherButtonTitles:nil];
-    
+    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
+                                                                              message:nil
+                                                                       preferredStyle:UIAlertControllerStyleActionSheet];
+    [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
+                                                        style:UIAlertActionStyleCancel
+                                                      handler:nil]];
+    __weak __typeof(self)weakSelf = self;
     for (XLFormLeftRightSelectorOption * leftOption in self.rowDescriptor.selectorOptions) {
-        [actionSheet addButtonWithTitle:[leftOption.leftValue displayText]];
-    }
-    actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-    actionSheet.tag = [self.rowDescriptor hash];
-    [actionSheet showInView:self.formViewController.view];
-#else
-    if ([UIAlertController class]) {
-        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
-                                                                                  message:nil
-                                                                           preferredStyle:UIAlertControllerStyleActionSheet];
-        [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
-                                                            style:UIAlertActionStyleCancel
-                                                          handler:nil]];
-        __weak __typeof(self)weakSelf = self;
-        for (XLFormLeftRightSelectorOption * leftOption in self.rowDescriptor.selectorOptions) {
-            [alertController addAction:[UIAlertAction actionWithTitle:[leftOption.leftValue displayText]
-                                                                style:UIAlertActionStyleDefault
-                                                              handler:^(UIAlertAction *action) {
-                                                                  weakSelf.rowDescriptor.value = [self chooseNewRightValueFromOption:leftOption];
-                                                                  weakSelf.rowDescriptor.leftRightSelectorLeftOptionSelected = [self leftOptionForDescription:[leftOption.leftValue displayText]].leftValue;
-                                                                  [weakSelf.formViewController updateFormRow:weakSelf.rowDescriptor];
-                                                              }]];
-        }
-        
-        [self.formViewController presentViewController:alertController animated:YES completion:nil];
-    }
-#ifndef XL_APP_EXTENSIONS
-    else{
-        UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                                  delegate:self cancelButtonTitle:nil
-                                                    destructiveButtonTitle:nil
-                                                         otherButtonTitles:nil];
-        
-        for (XLFormLeftRightSelectorOption * leftOption in self.rowDescriptor.selectorOptions) {
-            [actionSheet addButtonWithTitle:[leftOption.leftValue displayText]];
-        }
-        actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-        actionSheet.tag = [self.rowDescriptor hash];
-        [actionSheet showInView:self.formViewController.view];
-        
-        
-    }
-#endif
-#endif
-}
-
-#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
-
-#pragma mark - UIActionSheetDelegate
-
-- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    if ([actionSheet cancelButtonIndex] != buttonIndex){
-        NSString * title = [actionSheet buttonTitleAtIndex:buttonIndex];
-        if (![self.rowDescriptor.leftRightSelectorLeftOptionSelected isEqual:[self leftOptionForDescription:title].leftValue]){            
-            self.rowDescriptor.value = [self chooseNewRightValueFromOption:[self leftOptionForDescription:title]];
-            self.rowDescriptor.leftRightSelectorLeftOptionSelected = [self leftOptionForDescription:title].leftValue;
-            [self.formViewController updateFormRow:self.rowDescriptor];
-        }
+        [alertController addAction:[UIAlertAction actionWithTitle:[leftOption.leftValue displayText]
+                                                            style:UIAlertActionStyleDefault
+                                                          handler:^(UIAlertAction *action) {
+                                                              weakSelf.rowDescriptor.value = [self chooseNewRightValueFromOption:leftOption];
+                                                              weakSelf.rowDescriptor.leftRightSelectorLeftOptionSelected = [self leftOptionForDescription:[leftOption.leftValue displayText]].leftValue;
+                                                              [weakSelf.formViewController updateFormRow:weakSelf.rowDescriptor];
+                                                          }]];
     }
+    
+    [self.formViewController presentViewController:alertController animated:YES completion:nil];
 }
 
-#endif
-
-
 @end

+ 95 - 184
iOSClient/Library/XLForm/XL/Cell/XLFormSelectorCell.m

@@ -29,10 +29,9 @@
 #import "XLFormSelectorCell.h"
 #import "NSArray+XLFormAdditions.h"
 
-@interface XLFormSelectorCell() <UIActionSheetDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UIPopoverControllerDelegate>
+@interface XLFormSelectorCell() <UIPickerViewDelegate, UIPickerViewDataSource, UIPopoverPresentationControllerDelegate>
 
 @property (nonatomic) UIPickerView * pickerView;
-@property (nonatomic) UIPopoverController *popoverController;
 
 @end
 
@@ -168,21 +167,28 @@
             selectorViewController.title = self.rowDescriptor.selectorTitle;
 
             if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]) {
-                if (self.popoverController && self.popoverController.popoverVisible) {
-                    [self.popoverController dismissPopoverAnimated:NO];
-                }
-                self.popoverController = [[UIPopoverController alloc] initWithContentViewController:selectorViewController];
-                self.popoverController.delegate = self;
-                if ([selectorViewController conformsToProtocol:@protocol(XLFormRowDescriptorPopoverViewController)]){
-                    ((id<XLFormRowDescriptorPopoverViewController>)selectorViewController).popoverController = self.popoverController;
+                UIViewController *popoverController = self.formViewController.presentedViewController;
+                if (popoverController && popoverController.modalPresentationStyle == UIModalPresentationPopover) {
+                    [self.formViewController dismissViewControllerAnimated:NO completion:nil];
                 }
+                selectorViewController.modalPresentationStyle = UIModalPresentationPopover;
+                
+                selectorViewController.popoverPresentationController.delegate = self;
                 if (self.detailTextLabel.window){
-                    [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
-                }
-                else{
-                    [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+                    selectorViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height);
+                    selectorViewController.popoverPresentationController.sourceView = self.detailTextLabel;
+                    selectorViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
+                } else {
+                    selectorViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
+                    selectorViewController.popoverPresentationController.sourceView = self;
+                    selectorViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
                 }
-                [controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
+                
+                [self.formViewController presentViewController:selectorViewController
+                                                      animated:YES
+                                                    completion:nil];
+                [controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self]
+                                                    animated:YES];
             }
             else {
                 [controller.navigationController pushViewController:selectorViewController animated:YES];
@@ -194,16 +200,24 @@
             optionsViewController.title = self.rowDescriptor.selectorTitle;
 
 			if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]) {
-				self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
-                self.popoverController.delegate = self;
-                optionsViewController.popoverController = self.popoverController;
+                optionsViewController.modalPresentationStyle = UIModalPresentationPopover;
+                
+                optionsViewController.popoverPresentationController.delegate = self;
                 if (self.detailTextLabel.window){
-                    [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+                    optionsViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height);
+                    optionsViewController.popoverPresentationController.sourceView = self.detailTextLabel;
+                    optionsViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
+                } else {
+                    optionsViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
+                    optionsViewController.popoverPresentationController.sourceView = self;
+                    optionsViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
                 }
-                else{
-                    [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
-                }
-                [controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
+                
+                [self.formViewController presentViewController:optionsViewController
+                                                      animated:YES
+                                                    completion:nil];
+                [controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self]
+                                                    animated:YES];
 			} else {
 				[controller.navigationController pushViewController:optionsViewController animated:YES];
 			}
@@ -223,135 +237,76 @@
         optionsViewController.title = self.rowDescriptor.selectorTitle;
 
         if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]) {
-            self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
-            self.popoverController.delegate = self;
-            optionsViewController.popoverController = self.popoverController;
+            optionsViewController.modalPresentationStyle = UIModalPresentationPopover;
+            
+            optionsViewController.popoverPresentationController.delegate = self;
             if (self.detailTextLabel.window){
-                [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
-            }
-            else{
-                [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+                optionsViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height);
+                optionsViewController.popoverPresentationController.sourceView = self.detailTextLabel;
+                optionsViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
+            } else {
+                optionsViewController.popoverPresentationController.sourceRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
+                optionsViewController.popoverPresentationController.sourceView = self;
+                optionsViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
             }
+            
+            [self.formViewController presentViewController:optionsViewController
+                                                  animated:YES
+                                                completion:nil];
             [controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
         } else {
             [controller.navigationController pushViewController:optionsViewController animated:YES];
         }
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorActionSheet]){
-
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
-        UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                                  delegate:self
-                                                         cancelButtonTitle:nil
-                                                    destructiveButtonTitle:nil
-                                                         otherButtonTitles:nil];
+        XLFormViewController * formViewController = self.formViewController;
+        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
+                                                                                  message:nil
+                                                                           preferredStyle:UIAlertControllerStyleActionSheet];
+        [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
+                                                            style:UIAlertActionStyleCancel
+                                                          handler:nil]];
+        alertController.popoverPresentationController.sourceView = formViewController.tableView;
+        UIView* v = (self.detailTextLabel ?: self.textLabel) ?: self.contentView;
+        alertController.popoverPresentationController.sourceRect = [formViewController.tableView convertRect:v.frame fromView:self];
+        __weak __typeof(self)weakSelf = self;
         for (id option in self.rowDescriptor.selectorOptions) {
-            [actionSheet addButtonWithTitle:[option displayText]];
-        }
-        actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-        actionSheet.tag = [self.rowDescriptor hash];
-        [actionSheet showInView:controller.view];
-#else
-        if ([UIAlertController class]) {
-            XLFormViewController * formViewController = self.formViewController;
-            UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
-                                                                                      message:nil
-                                                                               preferredStyle:UIAlertControllerStyleActionSheet];
-            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
-                                                                style:UIAlertActionStyleCancel
-                                                              handler:nil]];
-            alertController.popoverPresentationController.sourceView = formViewController.tableView;
-            UIView* v = (self.detailTextLabel ?: self.textLabel) ?: self.contentView;
-            alertController.popoverPresentationController.sourceRect = [formViewController.tableView convertRect:v.frame fromView:self];
-            __weak __typeof(self)weakSelf = self;
-            for (id option in self.rowDescriptor.selectorOptions) {
-				NSString *optionTitle = [option displayText];
-				if (self.rowDescriptor.valueTransformer){
-					NSAssert([self.rowDescriptor.valueTransformer isSubclassOfClass:[NSValueTransformer class]], @"valueTransformer is not a subclass of NSValueTransformer");
-					NSValueTransformer * valueTransformer = [self.rowDescriptor.valueTransformer new];
-					NSString * transformedValue = [valueTransformer transformedValue:[option valueData]];
-					if (transformedValue) {
-						optionTitle = transformedValue;
-					}
-				}
-                [alertController addAction:[UIAlertAction actionWithTitle:optionTitle
-                                                                    style:UIAlertActionStyleDefault
-                                                                  handler:^(UIAlertAction *action) {
-                                                                      [weakSelf.rowDescriptor setValue:option];
-                                                                      [formViewController.tableView reloadData];
-                                                                  }]];
-            }
-            [formViewController presentViewController:alertController animated:YES completion:nil];
-        }
-#ifndef XL_APP_EXTENSIONS
-        else{
-            UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                                      delegate:self
-                                                             cancelButtonTitle:nil
-                                                        destructiveButtonTitle:nil
-                                                             otherButtonTitles:nil];
-            for (id option in self.rowDescriptor.selectorOptions) {
-                [actionSheet addButtonWithTitle:[option displayText]];
+            NSString *optionTitle = [option displayText];
+            if (self.rowDescriptor.valueTransformer){
+                NSAssert([self.rowDescriptor.valueTransformer isSubclassOfClass:[NSValueTransformer class]], @"valueTransformer is not a subclass of NSValueTransformer");
+                NSValueTransformer * valueTransformer = [self.rowDescriptor.valueTransformer new];
+                NSString * transformedValue = [valueTransformer transformedValue:[option valueData]];
+                if (transformedValue) {
+                    optionTitle = transformedValue;
+                }
             }
-            actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-            actionSheet.tag = [self.rowDescriptor hash];
-            [actionSheet showInView:controller.view];
+            [alertController addAction:[UIAlertAction actionWithTitle:optionTitle
+                                                                style:UIAlertActionStyleDefault
+                                                              handler:^(UIAlertAction *action) {
+                                                                  [weakSelf.rowDescriptor setValue:option];
+                                                                  [formViewController.tableView reloadData];
+                                                              }]];
         }
-#endif
-#endif
+        [formViewController presentViewController:alertController animated:YES completion:nil];
         [controller.tableView deselectRowAtIndexPath:[controller.form indexPathOfFormRow:self.rowDescriptor] animated:YES];
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorAlertView]){
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
-        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                             message:nil
-                                                            delegate:self
-                                                   cancelButtonTitle:nil
-                                                   otherButtonTitles:nil];
+        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
+                                                                                  message:nil
+                                                                           preferredStyle:UIAlertControllerStyleAlert];
+        __weak __typeof(self)weakSelf = self;
         for (id option in self.rowDescriptor.selectorOptions) {
-            [alertView addButtonWithTitle:[option displayText]];
-        }
-        alertView.cancelButtonIndex = [alertView addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-        alertView.tag = [self.rowDescriptor hash];
-        [alertView show];
-#else
-        if ([UIAlertController class]) {
-            UIAlertController * alertController = [UIAlertController alertControllerWithTitle:self.rowDescriptor.selectorTitle
-                                                                                      message:nil
-                                                                               preferredStyle:UIAlertControllerStyleAlert];
-            __weak __typeof(self)weakSelf = self;
-            for (id option in self.rowDescriptor.selectorOptions) {
-                [alertController addAction:[UIAlertAction actionWithTitle:[option displayText]
-                                                                    style:UIAlertActionStyleDefault
-                                                                  handler:^(UIAlertAction *action) {
-                                                                      [weakSelf.rowDescriptor setValue:option];
-                                                                      [weakSelf.formViewController.tableView reloadData];
-                                                                  }]];
-            }
-            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
-                                                                style:UIAlertActionStyleCancel
-                                                              handler:nil]];
-            [controller presentViewController:alertController animated:YES completion:nil];
-
-        }
-#ifndef XL_APP_EXTENSIONS
-        else{
-            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:self.rowDescriptor.selectorTitle
-                                                                 message:nil
-                                                                delegate:self
-                                                       cancelButtonTitle:nil
-                                                       otherButtonTitles:nil];
-            for (id option in self.rowDescriptor.selectorOptions) {
-                [alertView addButtonWithTitle:[option displayText]];
-            }
-            alertView.cancelButtonIndex = [alertView addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
-            alertView.tag = [self.rowDescriptor hash];
-            [alertView show];
+            [alertController addAction:[UIAlertAction actionWithTitle:[option displayText]
+                                                                style:UIAlertActionStyleDefault
+                                                              handler:^(UIAlertAction *action) {
+                                                                  [weakSelf.rowDescriptor setValue:option];
+                                                                  [weakSelf.formViewController.tableView reloadData];
+                                                              }]];
         }
-#endif
-#endif
+        [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
+                                                            style:UIAlertActionStyleCancel
+                                                          handler:nil]];
+        [controller presentViewController:alertController animated:YES completion:nil];
         [controller.tableView deselectRowAtIndexPath:[controller.form indexPathOfFormRow:self.rowDescriptor] animated:YES];
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPickerView]){
@@ -372,47 +327,6 @@
     self.detailTextLabel.textColor = _beforeChangeColor;
 }
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
-
-#pragma mark - UIActionSheetDelegate
-
-- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorActionSheet]){
-        if ([actionSheet cancelButtonIndex] != buttonIndex){
-            NSString * title = [actionSheet buttonTitleAtIndex:buttonIndex];
-            for (id option in self.rowDescriptor.selectorOptions){
-                if ([[option displayText] isEqualToString:title]){
-                    [self.rowDescriptor setValue:option];
-                    [self.formViewController.tableView reloadData];
-                    break;
-                }
-            }
-        }
-    }
-}
-
-
-#pragma mark - UIAlertViewDelegate
-
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorAlertView]){
-        if ([alertView cancelButtonIndex] != buttonIndex){
-            NSString * title = [alertView buttonTitleAtIndex:buttonIndex];
-            for (id option in self.rowDescriptor.selectorOptions){
-                if ([[option displayText] isEqualToString:title]){
-                    [self.rowDescriptor setValue:option];
-                    [self.formViewController.tableView reloadData];
-                    break;
-                }
-            }
-        }
-    }
-}
-
-#endif
-
 #pragma mark - UIPickerViewDelegate
 
 - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
@@ -449,6 +363,11 @@
     return self.rowDescriptor.selectorOptions.count;
 }
 
+#pragma mark - UIPopoverPresentationControllerDelegate
+
+- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
+    [self.formViewController.tableView reloadData];
+}
 
 #pragma mark - Helpers
 
@@ -493,12 +412,4 @@
     return nil;
 }
 
-
-#pragma mark - UIPopoverControllerDelegate
-
-- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
-{
-    [self.formViewController.tableView reloadData];
-}
-
 @end

+ 1 - 1
iOSClient/Library/XLForm/XL/Controllers/XLFormOptionsViewController.h

@@ -28,7 +28,7 @@
 #import "XLFormRowDescriptorViewController.h"
 #import "XLFormRowDescriptor.h"
 
-@interface XLFormOptionsViewController : UITableViewController<XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController>
+@interface XLFormOptionsViewController : UITableViewController<XLFormRowDescriptorViewController>
 
 - (instancetype)initWithStyle:(UITableViewStyle)style;
 

+ 2 - 4
iOSClient/Library/XLForm/XL/Controllers/XLFormOptionsViewController.m

@@ -45,7 +45,6 @@
 @synthesize titleHeaderSection = _titleHeaderSection;
 @synthesize titleFooterSection = _titleFooterSection;
 @synthesize rowDescriptor = _rowDescriptor;
-@synthesize popoverController = __popoverController;
 
 - (instancetype)initWithStyle:(UITableViewStyle)style
 {
@@ -153,9 +152,8 @@
             self.rowDescriptor.value = cellObject;
             cell.accessoryType = UITableViewCellAccessoryCheckmark;
         }
-        if (self.popoverController){
-            [self.popoverController dismissPopoverAnimated:YES];
-            [self.popoverController.delegate popoverControllerDidDismissPopover:self.popoverController];
+        if (self.modalPresentationStyle == UIModalPresentationPopover){
+            [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
         }
         else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
             [self.navigationController popViewControllerAnimated:YES];

+ 0 - 8
iOSClient/Library/XLForm/XL/Controllers/XLFormRowDescriptorViewController.h

@@ -32,12 +32,4 @@
 @required
 @property (nonatomic) XLFormRowDescriptor * rowDescriptor;
 
-@end
-
-@protocol XLFormRowDescriptorPopoverViewController <NSObject>
-
-@required
-@property (nonatomic) UIPopoverController * popoverController;
-
-
 @end

+ 1 - 1
iOSClient/Library/XLForm/XL/Controllers/XLFormViewController.h

@@ -79,7 +79,7 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
 
 @end
 
-@interface XLFormViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, UIActionSheetDelegate, XLFormViewControllerDelegate>
+@interface XLFormViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, XLFormViewControllerDelegate>
 
 @property XLFormDescriptor * form;
 @property IBOutlet UITableView * tableView;

+ 14 - 56
iOSClient/Library/XLForm/XL/Controllers/XLFormViewController.m

@@ -462,66 +462,24 @@
 
 -(void)showFormValidationError:(NSError *)error
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
-    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"XLFormViewController_ValidationErrorTitle", nil)
-                                                         message:error.localizedDescription
-                                                        delegate:self
-                                               cancelButtonTitle:NSLocalizedString(@"OK", nil)
-                                               otherButtonTitles:nil];
-    [alertView show];
-#else
-    if ([UIAlertController class]){
-        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"XLFormViewController_ValidationErrorTitle", nil)
-                                                                                  message:error.localizedDescription
-                                                                           preferredStyle:UIAlertControllerStyleAlert];
-        [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
-                                                            style:UIAlertActionStyleDefault
-                                                          handler:nil]];
-        [self presentViewController:alertController animated:YES completion:nil];
-    }
-#ifndef XL_APP_EXTENSIONS
-    else{
-        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"XLFormViewController_ValidationErrorTitle", nil)
-                                                             message:error.localizedDescription
-                                                            delegate:self
-                                                   cancelButtonTitle:NSLocalizedString(@"OK", nil)
-                                                   otherButtonTitles:nil];
-        [alertView show];
-    }
-#endif
-#endif
+    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"XLFormViewController_ValidationErrorTitle", nil)
+                                                                              message:error.localizedDescription
+                                                                       preferredStyle:UIAlertControllerStyleAlert];
+    [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
+                                                        style:UIAlertActionStyleDefault
+                                                      handler:nil]];
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 -(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
-    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
-                                                         message:error.localizedDescription
-                                                        delegate:self
-                                               cancelButtonTitle:NSLocalizedString(@"OK", nil)
-                                               otherButtonTitles:nil];
-    [alertView show];
-#else
-    if ([UIAlertController class]){
-        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(title, nil)
-                                                                                  message:error.localizedDescription
-                                                                           preferredStyle:UIAlertControllerStyleAlert];
-        [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
-                                                            style:UIAlertActionStyleDefault
-                                                          handler:nil]];
-        [self presentViewController:alertController animated:YES completion:nil];
-    }
-#ifndef XL_APP_EXTENSIONS
-    else{
-        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
-                                                             message:error.localizedDescription
-                                                            delegate:self
-                                                   cancelButtonTitle:NSLocalizedString(@"OK", nil)
-                                                   otherButtonTitles:nil];
-        [alertView show];
-    }
-#endif
-#endif
+    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(title, nil)
+                                                                              message:error.localizedDescription
+                                                                       preferredStyle:UIAlertControllerStyleAlert];
+    [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
+                                                        style:UIAlertActionStyleDefault
+                                                      handler:nil]];
+    [self presentViewController:alertController animated:YES completion:nil];
 }
 
 -(void)performFormSelector:(SEL)selector withObject:(id)sender