I want to reload a simple UIWebView I have loaded when the app opens and closes from the iPad Home Button.
I've searched other questions, but none seem to fit as I don't want an extra button or Tab or something else in my app.
I tried:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[webView reload];
}
but this doesn't react. My initialization code is in a controller derived from UIViewController and the UIwebview is initialized in - (void)viewDidLoad
Any clue how to do this?
Kind regards
Try refreshing your view in
applicationWillEnterForeground:
. This message is sent to your application delegate when the application resumes after having been put in the background with the home button.Do you mean you want to refresh the web view when the user resumes the app after multitasking? In that case, what you're after is the applicationWillEnterForeground: method in your
UIApplicationDelegate
.General information on multitasking is here.
As people have pointed out you probably want the
applicationWillEnterForeground:
call but don't be tempted to add a load of junk to your app delegate.Instead - you should register to receive this notification when you init the
UIViewController
that contains theUIWebView
.Then implement the refresh method something like:
You will need to unregister in your dealloc to avoid any nasty suprises something like this