Fix[picker]: adjust checkmark location

This commit is contained in:
Duy Tran Khanh committed 2023-07-25 14:44:52 +07:00
1 parent 6ede0a3a71
commit b53a38d694
1 file changed
+5 -4
+5 -4
View File
@@ -358,13 +358,11 @@
NSArray *pickKeys = item[@"pickKeys"];
NSArray *pickList = item[@"pickList"];
NSMutableArray *menuItems = [[NSMutableArray alloc] init];
NSMutableArray<UIAction *> *menuItems = [[NSMutableArray alloc] init];
for (int i = 0; i < pickList.count; i++) {
BOOL selected = [cell.detailTextLabel.text isEqualToString:pickKeys[i]];
[menuItems addObject:[UIAction
actionWithTitle:pickList[i]
image:(selected ? [UIImage systemImageNamed:@"checkmark"] : nil)
identifier:nil
image:nil identifier:nil
handler:^(UIAction *action) {
cell.detailTextLabel.text = pickKeys[i];
self.setPreference(self.prefSections[indexPath.section], item[@"key"], pickKeys[i]);
@@ -373,6 +371,9 @@
invokeAction(pickKeys[i]);
}
}]];
if ([cell.detailTextLabel.text isEqualToString:pickKeys[i]]) {
menuItems.lastObject.state = UIMenuElementStateOn;
}
}
self.currentMenu = [UIMenu menuWithTitle:message children:menuItems];