Different settings for different devices?

I am developing a universal iOS application that has some settings that do not make sense for certain devices. In particular, I would like to hide certain settings from the user on devices where the portrait width is below the threshold. (So, for example, some settings should not be available on the iPhone 7, but should be available on the iPhone 7 Plus.)

I know that it is possible to have different settings for iPhone and iPad devices (as described in this thread ), but this is not what I need. I am also familiar with class size mock-ups , but that doesn't seem like settings.

Is it possible to hide (or at least disable) certain settings depending on the size of the device on which the application is running?

On the same lines, is it possible to have default values ​​for settings depending on the size of the display?

+6
source share
1 answer

Sorry, but this is not possible. You are right that all you can do is different settings. Package for iPads and iPhones. Since iOS 4 Settings plists may be device dependent: Root ~ ipad.plist will be used on iPad and Root ~ iphone.plist on iPhone. If not, Root.plist will be used.

So, from my point of view, you can achieve part of your goal using these 2 settings. For more specific cases, you can set some default values ​​at application startup. Settings.bundle cannot be changed directly from the code, so you cannot delete or disable certain settings, but you can change its value to a specific default value for a specific device. Each item in Settings.bundle is associated with a key in NSUserDefaults , so you can simply set the values ​​in NSUserDefaults , and the settings application will automatically reflect this. However, this will be saved elsewhere. You can simply read it in the same way as with a set of settings, also through NSUserDefaults .

You can find sample code in this answer fooobar.com/questions/1014481 / ...

Another interesting option is to use https://github.com/futuretap/InAppSettingsKit , which adds the same with its own settings interface to the application. And these internal settings are synchronized with the device settings, but you have more control over it.

+2
source

Source: https://habr.com/ru/post/1014479/


All Articles