Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picker reappears when specifier's property changed programmatically #10

Open
udevsharold opened this issue Jun 2, 2020 · 0 comments
Open

Comments

@udevsharold
Copy link

udevsharold commented Jun 2, 2020

I'm implementing this in one of my tweak, and the picker specifiers are dynamically enabled and disabled based on a switch. Every time the switch is toggled, last picker (it consist of three pickers in prefs) will pop-up. I'm not sure is this issue occurs because of how I implement it, or it's on how Alderis' implementation. Sample code:

In RootListController.m:

- (NSArray *)specifiers {
    if (!_specifiers) {
        _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
        NSArray *pickerCell = @[@"picker1", @"picker2",@"picker3"];
        self.pickerSpecifiers = (!self.pickerSpecifiers) ? [[NSMutableDictionary alloc] init] : self.pickerSpecifiers ;
        for(PSSpecifier *specifier in _specifiers) {
            if([pickerCell containsObject:[specifier propertyForKey:@"tag"]]) {
                [self.pickerSpecifiers setObject:specifier forKey:[specifier propertyForKey:@"tag"]];
            }
        }
    }
    return _specifiers;
}

- (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier{
    [super setPreferenceValue:value specifier:specifier];
    NSString *key = [specifier propertyForKey:@"key"];
    if([key isEqualToString:@"theswitch"]) {
        [(PSSpecifier *)self.pickerSpecifiers [@"picker1tag"] setProperty:value forKey:@"enabled"];
        [self reloadSpecifier:(PSSpecifier *)self.pickerSpecifiers [@"pickertag1"] animated:NO]; //It should be this line caused the last picker to pop-up to due to the reloading
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant