ios - UIActivityIndicator on UIWebView starts spinning on link from page-doesn't stop -
i'm using uiactivityindicator on uiwebview indicate page loading, , it's working fine. however, on pages, when click link navigate further down page, indicator starts spinning again , doesn't stop. happens after page has loaded correctly.
code:
- (void)viewdidload { [super viewdidload]; [self loadwebviewrequest]; self.back = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"backbutton"] style:uibarbuttonitemstyleplain target:self action:@selector(backbutton)]; self.forward = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"forwardbutton"] style:uibarbuttonitemstyleplain target:self action:@selector(forwardbutton)]; self.navigationitem.rightbarbuttonitems = [[nsarray alloc] initwithobjects:_forward, _back, nil]; self.forward.enabled = no; self.back.enabled = no; self.thebool = false; self.webview.delegate = self; } -(void) backbutton { [self.webview goback]; } -(void) forwardbutton { [self.webview goforward]; } -(void) webviewdidfinishload:(uiwebview *)webview { if (self.webview.cangoforward) { self.forward.enabled = yes; } else { self.forward.enabled = no; } if (self.webview.cangoback) { self.back.enabled = yes; } else { self.back.enabled = no; } self.refresh.enabled = yes; [self.activityindicator stopanimating]; } -(bool) webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { self.refresh.enabled = no; [self.activityindicator startanimating]; uibarbuttonitem *backbutton = [[uibarbuttonitem alloc] initwithtitle:@"reference" style:uibarbuttonitemstyleplain target:nil action:nil]; self.navigationitem.backbarbuttonitem = backbutton; return yes; } -(void) webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error{ [self.activityindicator stopanimating]; self.refresh.enabled = yes; nslog(@"whoops"); } -(void) loadwebviewrequest { nsurl *url = [[nsurl alloc] initwithstring:self.urlstring]; nsurlrequest *request = [[nsurlrequest alloc] initwithurl:url]; [self.webview loadrequest:request]; } thanks
Comments
Post a Comment