我一直在嘗試很長一段時間才能找到解決方案,應該是一個非常簡單的問題。 我想要的是在應用程序未運行時可以在iPhone設置菜單中編輯的變量。基本上是一個包裝在iOS GUI中的配置文件。訪問Xamarin.iOS Settings.Bundle?
這應該是iOS中的內置功能,雖然我可以找到一些與之相關的方法,但我找不到實際的解決方案。
最近我一直想得到我想要的東西就像其他變量一樣工作:在應用程序啓動時清空,並在應用程序關閉時再次被擦傷。並且在iPhone設置窗口中仍然不可見。
這是我的代碼有:
private void LoadSettingsFromIOS()
{
// This is where it works like any other variable. Aka. gets scratched on app closing.
_thisUser.SetValueForKey(new NSString("Blargh"), new NSString("SaveCredentials"));
string stringForKey = _thisUser.StringForKey("SaveCredentials");
// This is where I'm supposed to be able to load the data from settings and set the checkbox's 'On' state to the value. Currently it always returns False.
bool saveCredentials = _thisUser.BoolForKey("SaveCredentials");
chckBoxRememberMe.On = saveCredentials;
}
而且我Settings.Bundle Root.pList文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Credentials</string>
<key>Key</key>
<string>SaveCredentials</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
任何人在那裏是誰在瞎與Xamarin iOS和知道如何工作的?