Recently I've been developing a tweak for Cydia using an excellent framework (Theos by the awesome Dustin Howett) and I'd like to know whether there is any way to grey out a cell in the preference bundle of the tweak. It doesn't matter whether it will require a private API as this is for a jailbroken environment. Any help, links or references are greatly appreciated. I'm using a private framework (Preferences.framework)
.
Asked
Active
Viewed 1,494 times
2

s6luwJ0A3I
- 1,023
- 1
- 9
- 22
1 Answers
1
I don't have my jailbroken phone with me, so I can't test this, but if you look at the Preferences docs on iphonedevwiki, you'll see that there is a flag that will gray out preference items (enabled
). So, you might use a chunk of code in your preferences plist file like this:
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.mycompany.myapp</string>
<key>key</key>
<string>wifi_location</string>
<key>label</key>
<string>WiFi Location</string>
<key>enabled</key>
<false/> <!-- gray out this item -->
</dict>
If you look at the preference loader docs, you see that you also can inject code into Preferences.app, which would probably allow you to set this flag dynamically (probably needed if you're tweaking an app that's not yours).
I'll try to test this later, and hopefully, update this answer.

Nate
- 31,017
- 13
- 83
- 207
-
@SuperDev, Right. If you have `
id SomeSpecifierId ` in the plist file, then you can probably get the `PSSpecifier` that corresponds to it. Or, you could probably iterate through all specifiers and look for the right label. Then, on your `PSSpecifier` instance, use `setProperty:forKey:` to change the `enabled` key's value (property) to `NO` (or maybe `[NSNumber numberWithBool:NO]`) – Nate Feb 03 '13 at 09:08 -
I would think so, but looking at the API, `setProperty:` wants an `id` value, so it might need `[specifier setProperty: [NSNumber numberWithBool: NO] forKey: @"enabled"]`. I'm switching between languages right now, and can't remember if autoboxing works in Objective-C :/ – Nate Feb 03 '13 at 10:42
-
@SuperDev, also, I'm not clear on whether you are creating this Preference Bundle yourself, to be used by your tweak, or whether you are tweaking an existing app that already has a Settings or Preference Bundle. That would affect how you get at this stuff. But, maybe you've already figured out that part, and just need to know what code to use, once you've properly hooked your **code** into Preferences.app. – Nate Feb 03 '13 at 10:45
-
If you have more specific questions, feel free to ask here. I can't do chat, though, as that forces me to hang around and get interrupted constantly. My last question was just checking that you were **creating** the prefs bundle yourself, and not trying to tweak another app's. Given that you said "yes", you should be able to follow the tutorial in the link I posted, and implement your own `PSListController` subclass. Get the specifiers and modify them. I'm not sure, but if the changes don't take affect immediately, you might need to call the controller's `updateSpecifiers:withSpecifiers`. – Nate Feb 03 '13 at 21:56
-
@SuperDev, it's linked to from the references in my answer, but I just thought I'd call out that this seems like a pretty complete tutorial as well: http://www.touchrepo.com/guides/preferencebundles/PreferenceBundles.doc – Nate Feb 03 '13 at 21:57