我创建了设置包,我在其中添加了一个文本字段,我需要将 url 从它加载到 uiwebview。我想为其添加默认值,但在更改加载后它不会加载到 uiwebview 中。
请帮忙!
<dict>
<key>KeyboardType</key>
<string>URL</string>
<key>DefaultValue</key>
<string>http://iscientist.ru/</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Домашняя страничка 1</string>
<key>Key</key>
<string>url1</string>
</dict>
<dict>
<key>KeyboardType</key>
<string>URL</string>
<key>DefaultValue</key>
<string>http://google.com/</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Домашняя страничка 2</string>
<key>Key</key>
<string>url2</string>
</dict>
和代码:
NSString *settingValue1 = [[NSUserDefaults standardUserDefaults] stringForKey:@"url1"];
NSURL *urlx1 = [NSURL URLWithString:[NSString stringWithFormat:@"%@", settingValue1]];
NSURLRequest *request1 = [NSURLRequest requestWithURL:urlx1];
[_webView loadRequest:request1];
NSString *settingValue2 = [[NSUserDefaults standardUserDefaults] stringForKey:@"url2"];
NSURL *urlx2 = [NSURL URLWithString:[NSString stringWithFormat:@"%@", settingValue2]];
NSURLRequest *request2 = [NSURLRequest requestWithURL:urlx2];
[webView2 loadRequest:request2];