@@ -338,17 +338,34 @@ - (void)showSpeedPicker {
338
338
[[NSUserDefaults standardUserDefaults ] setFloat: speed.floatValue forKey: @" DYYYDefaultSpeed" ];
339
339
[[NSUserDefaults standardUserDefaults ] synchronize ];
340
340
341
- NSIndexPath *indexPath = [NSIndexPath indexPathForRow: 2 inSection: 0 ];
342
- UITableViewCell *cell = [self .tableView cellForRowAtIndexPath: indexPath];
343
- UITextField *speedField = [cell.accessoryView viewWithTag: 999 ];
344
- speedField.text = [NSString stringWithFormat: @" %.2f " , speed.floatValue];
341
+ for (NSInteger section = 0 ; section < self.settingSections .count ; section++) {
342
+ NSArray *items = self.settingSections [section];
343
+ for (NSInteger row = 0 ; row < items.count ; row++) {
344
+ DYYYSettingItem *item = items[row];
345
+ if (item.type == DYYYSettingItemTypeSpeedPicker) {
346
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow: row inSection: section];
347
+ UITableViewCell *cell = [self .tableView cellForRowAtIndexPath: indexPath];
348
+ UITextField *speedField = [cell.accessoryView viewWithTag: 999 ];
349
+ if (speedField) {
350
+ speedField.text = [NSString stringWithFormat: @" %.2f " , speed.floatValue];
351
+ }
352
+ break ;
353
+ }
354
+ }
355
+ }
345
356
}];
346
357
[alert addAction: action];
347
358
}
348
359
349
360
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle: @" 取消" style: UIAlertActionStyleCancel handler: nil ];
350
361
[alert addAction: cancelAction];
351
362
363
+ if (UIDevice.currentDevice .userInterfaceIdiom == UIUserInterfaceIdiomPad) {
364
+ UITableViewCell *selectedCell = [self .tableView cellForRowAtIndexPath: [self .tableView indexPathForSelectedRow ]];
365
+ alert.popoverPresentationController .sourceView = selectedCell;
366
+ alert.popoverPresentationController .sourceRect = selectedCell.bounds ;
367
+ }
368
+
352
369
[self presentViewController: alert animated: YES completion: nil ];
353
370
}
354
371
0 commit comments