Skip to content

Commit 7d221c6

Browse files
committed
Fixed viewing issues on iPad
1 parent 33255c7 commit 7d221c6

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

DYYYSettingViewController.m

+21-4
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,34 @@ - (void)showSpeedPicker {
338338
[[NSUserDefaults standardUserDefaults] setFloat:speed.floatValue forKey:@"DYYYDefaultSpeed"];
339339
[[NSUserDefaults standardUserDefaults] synchronize];
340340

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+
}
345356
}];
346357
[alert addAction:action];
347358
}
348359

349360
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
350361
[alert addAction:cancelAction];
351362

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+
352369
[self presentViewController:alert animated:YES completion:nil];
353370
}
354371

0 commit comments

Comments
 (0)