mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-06-08 11:32:36 +00:00
cache bundle icons manually
otherwise they seem to get mixed up on iOS 14
This commit is contained in:
parent
b72a6f058a
commit
af3b2ba5b1
|
@ -27,6 +27,7 @@ typedef enum : NSInteger {
|
||||||
NSArray *keyboardLayouts;
|
NSArray *keyboardLayouts;
|
||||||
NSArray<NSBundle*> *emulatorBundles;
|
NSArray<NSBundle*> *emulatorBundles;
|
||||||
NSMutableArray *machineList; // NSString (header) or NSBundle (emulator bundle)
|
NSMutableArray *machineList; // NSString (header) or NSBundle (emulator bundle)
|
||||||
|
NSMutableDictionary<NSString*,UIImage*> *bundleIcons;
|
||||||
NSMutableSet<NSBundle*> *groupedEmulatorBundles;
|
NSMutableSet<NSBundle*> *groupedEmulatorBundles;
|
||||||
NSBundle *selectedEmulatorBundle;
|
NSBundle *selectedEmulatorBundle;
|
||||||
NSString *aboutTitle;
|
NSString *aboutTitle;
|
||||||
|
@ -48,6 +49,7 @@ typedef enum : NSInteger {
|
||||||
|
|
||||||
- (void)loadEmulatorBundles {
|
- (void)loadEmulatorBundles {
|
||||||
emulatorBundles = [AppDelegate sharedInstance].emulatorBundles;
|
emulatorBundles = [AppDelegate sharedInstance].emulatorBundles;
|
||||||
|
bundleIcons = [NSMutableDictionary dictionaryWithCapacity:emulatorBundles.count];
|
||||||
NSMutableDictionary<NSString*,NSMutableArray<NSBundle*>*> *bundlesByName = [NSMutableDictionary dictionaryWithCapacity:emulatorBundles.count];
|
NSMutableDictionary<NSString*,NSMutableArray<NSBundle*>*> *bundlesByName = [NSMutableDictionary dictionaryWithCapacity:emulatorBundles.count];
|
||||||
NSString *selectedBundleName = [[NSUserDefaults standardUserDefaults] stringForKey:@"machine"];
|
NSString *selectedBundleName = [[NSUserDefaults standardUserDefaults] stringForKey:@"machine"];
|
||||||
for (NSBundle *bundle in emulatorBundles) {
|
for (NSBundle *bundle in emulatorBundles) {
|
||||||
|
@ -270,8 +272,7 @@ typedef enum : NSInteger {
|
||||||
cell.imageView.image = nil;
|
cell.imageView.image = nil;
|
||||||
cell.indentationLevel = 1;
|
cell.indentationLevel = 1;
|
||||||
} else {
|
} else {
|
||||||
NSString *iconName = [NSString stringWithFormat:@"%@/Icon", bundle.bundlePath];
|
cell.imageView.image = [self iconForBundle:bundle];
|
||||||
cell.imageView.image = [UIImage imageNamed:iconName];
|
|
||||||
cell.indentationLevel = 0;
|
cell.indentationLevel = 0;
|
||||||
}
|
}
|
||||||
cell.accessoryType = (item == selectedEmulatorBundle) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
cell.accessoryType = (item == selectedEmulatorBundle) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
||||||
|
@ -298,6 +299,19 @@ typedef enum : NSInteger {
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UIImage*)iconForBundle:(NSBundle*)bundle {
|
||||||
|
UIImage *icon = bundleIcons[bundle.bundlePath];
|
||||||
|
if (icon != nil) {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
NSString *iconPath = [NSString stringWithFormat:@"%@/Icon.png", bundle.bundlePath];
|
||||||
|
icon = [UIImage imageWithContentsOfFile:iconPath];
|
||||||
|
if (icon != nil) {
|
||||||
|
bundleIcons[bundle.bundlePath] = icon;
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
- (UITableViewCell*)aboutCellForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
|
- (UITableViewCell*)aboutCellForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
|
||||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"about" forIndexPath:indexPath];
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"about" forIndexPath:indexPath];
|
||||||
NSDictionary<NSString*,NSString*> *item = aboutItems[indexPath.row];
|
NSDictionary<NSString*,NSString*> *item = aboutItems[indexPath.row];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user