very simple question. I have an app with a single view (webview) that loads a url. The app has a settings bundle attached to it with one field asking for a string. Here is the code in my viewcontroller:
-(void)viewDidLoad{
[super viewDidLoad];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *settingString = [prefs stringForKey:@"name_preference"];
[pr开发者_StackOverflow中文版efs synchronize];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.stackoverflow.com/%@", settingString]]]];
}
So Far So good right. It takes the string from settings and concatenates the end of the url and all is well. when i run in the simulator i have to close the sim everytime to update the view if i change the string in settings. Is there somewhere else i should put this code instead of "viewDidLoad"? I want my webview to update everytime i re-open my app from settings. Thanks for all of your help....
You can put it in viewDidAppear
(in the vc) or applicationDidEnterForeground
in your app delegate.
The problem you're having is when you 'launch' the app by tapping it on the home screen, you're actually just using iOS's multitasking to switch back to it (it never quit).
What Alex said will work. But Apple will never accept an app with only one UIWebView
. I hope there's more to your app if you're hoping to publish it.
精彩评论