IOS/Objective-C: Deallocate web view in Detail View Controller -


i have master table , detail view controller. detail vc shows urls through web view.

if using built in navigation of master/detail setup, if go , press different table cell, detail view update web view. true whether use uiwebview or wkwebview.

however, within detail view, without having go table, want give user option view more 1 url through same web view. trying in viewwillappear changing url request. however, uiwebview (or alternatively wkwebview) continue show same url. can't seem rid of first url.

i've tried kinds of ways close or stop existing web view, clear cache, delete cookies etc. before reloading new 1 still see same url. appreciate suggestions. here code , of things i've tried don't work:

      -(void) changeurl: (nsnumber*)param {       nsurl *testurl1=[nsurl urlwithstring:@"http://www.apple.com"];       nsurl *testurl2 =[nsurl urlwithstring:@"http://www.google.com"];       //if param 1 {       _urltoload = testurl1;}       else {       _urltoload = testurl2;}       } edit: method below updateinterface, not viewwillappear      -(void) updateinterface {         uiwebview *webview;         nsurlrequest *request=[nsurlrequest requestwithurl:_urltoload];           webview = nil;//this blocks web view loading @ reason can't understand.  setting wkwebview nil not block loading.         [webview stoploading];//no effect         [webview loadrequest:request];          [[nsurlcache sharedurlcache] removecachedresponseforrequest:request];             [[nsurlcache sharedurlcache] removeallcachedresponses];             nsstring *mydomain = @"www.google.com";             for(nshttpcookie *cookie in [[nshttpcookiestorage sharedhttpcookiestorage] cookies]) {                  if([[cookie domain] isequaltostring:mydomain]) {                      [[nshttpcookiestorage sharedhttpcookiestorage] deletecookie:cookie];                 }             }      //wkwebview version             wkwebview *wkwebview;             wkwebviewconfiguration *wkconfig = [[wkwebviewconfiguration alloc] init];             wkwebview = nil;             wkwebview = [[wkwebview alloc] initwithframe:self.view.frame configuration:wkconfig];             wkwebview.navigationdelegate = self;             [wkwebview loadrequest:request];              [webview addsubview:wkwebview];              cgrect webframe = [[uiscreen mainscreen] applicationframe];             webframe.origin.y = 100.0; // statusbar             webframe.origin.y -= 100.0; // statusbar 20 px cut y of frame             webview = [[uiwebview alloc] initwithframe:webframe];            } 

the uiviewcontroller method "viewwillappear" has following signature in objective-c:

- (void)viewwillappear:(bool)animated 

, implemented without arguments.

the result that, instead of being taken override of original method defined in superclass uiviewcontroller, treated brand new, custom method introduced subclass; , unless call explicitly somewhere, never execute.

source: sdk reference


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -