I created an iOS app in Xcode. There are four ViewControllers in my app. You can navigate through the app by tapping the buttons in the bottom toolbar.
How can I prevent a ViewController from reloading when visiting it again?
So there are a couple of ways to keep track of whether the view has been loaded or not. One way is to create singleton and add several boolean properties to monitor whether the view has been loaded. Another way is to us NSUserDefaults to store a property once it has been loaded the first time. If you go that route then here is what the code would look like in your viewDidLoad method:
if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"homeLoadFlag"] isEqualToString:@"YES"]) {
NSURL *url=[NSURL URLWithString: @"http://google.com"];
NSURLRequest * requestURL=[NSURLRequest requestWithURL:url];
[_homewebview loadRequest:requestURL];
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"homeLoadFlag"];}
This place a wrapper around your call to load the webView and will only make the call when it's loaded the first time.