Просмотр исходного кода

Convert network settings action sheet to UIAlertController

Ryan Olson лет назад: 6
Родитель
Сommit
89b9ece45d
1 измененных файлов с 8 добавлено и 11 удалено
  1. 8 11
      Classes/Network/FLEXNetworkSettingsTableViewController.m

+ 8 - 11
Classes/Network/FLEXNetworkSettingsTableViewController.m

@@ -74,8 +74,14 @@
 
 - (void)clearRequestsTapped:(UIButton *)sender
 {
-    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Clear Recorded Requests" otherButtonTitles:nil];
-    [actionSheet showInView:self.view];
+    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
+    [actionSheet addAction:[UIAlertAction actionWithTitle:@"Clear Recorded Requests" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+        [[FLEXNetworkRecorder defaultRecorder] clearRecordedActivity];
+    }]];
+    self.popoverPresentationController.sourceView = sender;
+    self.popoverPresentationController.sourceRect = sender.bounds;
+    [self presentViewController:actionSheet animated:YES completion:nil];
 }
 
 #pragma mark - Table view data source
@@ -95,15 +101,6 @@
     return self.cells[indexPath.row];
 }
 
-#pragma mark - UIActionSheetDelegate
-
-- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    if (buttonIndex != actionSheet.cancelButtonIndex) {
-        [[FLEXNetworkRecorder defaultRecorder] clearRecordedActivity];
-    }
-}
-
 #pragma mark - Helpers
 
 - (UITableViewCell *)switchCellWithTitle:(NSString *)title toggleAction:(SEL)toggleAction isOn:(BOOL)isOn