iphone - Webview content is not readable after stop animating loading image -


i building 1 iphone application have 2 views 1 login view , web view. when user enters login credentials, redirect web view. while loading webview login view time taking load. hence used alertview show loading image.

@interface focusviewcontroller () @end  @implementation focusviewcontroller  @synthesize txtsecurecode; @synthesize webview; @synthesize organizationcode;  uiactivityindicatorview *indicator; uialertview *alert;  - (void)viewdidload { [super viewdidload]; appdelegate = (focusappdelegate *)[[uiapplication sharedapplication]delegate];  if(appdelegate.data.strorganizationcode == nil || appdelegate.data.straccesscode == nil) {     nslog(@"your first screen");     _loginview.hidden = no;      webview.hidden = yes; } else {     nslog(@"load webview directly\n");     nslog(@"organization code -> %@ \n secure access code -> %@",appdelegate.data.strorganizationcode,appdelegate.data.straccesscode);      organizationcode.text = appdelegate.data.strorganizationcode ;     txtsecurecode.text = appdelegate.data.straccesscode;     [self loginclicked:nil];       webview.hidden = no;     _loginview.hidden = yes;     }   }  - (ibaction)loginclicked:(id)sender {  @try {      if([[txtsecurecode text] isequaltostring:@""]  || [[organizationcode text] isequaltostring:@""] ) {         [self alertstatus:@"please enter access code" :@"login failed!":0];     }     else     {         nsstring *post =[[nsstring alloc] initwithformat:@"txtsecurecode=%@ @&password=%@",[txtsecurecode text],[organizationcode text]];         nsmutableurlrequest *request = [[[nsmutableurlrequest alloc] init] autorelease];          nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:@"http://myexample.com/accountservice/security/validateaccess?accesscode=%@&companycode=%@&type=1", txtsecurecode.text, organizationcode.text]];          nsstring *responsedata = [[nsstring alloc]initwithdata:[nsdata datawithcontentsofurl:url] encoding:nsutf8stringencoding];          if([responsedata isequaltostring:@""]){             [self alertstatus:@"please enter valid access code" :@"login failed !" :0];         }         else         {             appdelegate.data.strorganizationcode = organizationcode.text;             appdelegate.data.straccesscode = txtsecurecode.text;              [focusappdelegate addcustomobjecttouserdefaults:appdelegate.data key:kcredentails];              //updated             _loginview.hidden = yes;              webview.hidden = no;              responsedata = [responsedata stringbyreplacingoccurrencesofstring:@" "" " withstring:@""];             nsstring* encodedstring = [responsedata stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];              nslog(@"response ==> %@" ,encodedstring);              alert = [[[uialertview alloc] initwithtitle:@"loading\nplease wait..." message:nil delegate:self cancelbuttontitle:nil otherbuttontitles: nil] autorelease];              [alert show];              uiactivityindicatorview *indicator = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylewhite];             indicator.center = cgpointmake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);                             [indicator startanimating];                             [alert addsubview:indicator];                             [indicator release];              webview.backgroundcolor = [uicolor clearcolor];             webview.opaque = no;             webview.delegate = self;             webview.frame = self.view.bounds;              nsstring* urltwo = [[encodedstring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]                                 stringbyreplacingoccurrencesofstring:@"%22" withstring:@""];              nsurl *url2;              if([urltwo hasprefix:@"http://"]){                 url2 = [nsurl urlwithstring:urltwo];             }else{                 url2 = [nsurl urlwithstring:[nsstring stringwithformat:@"http://%@" , urltwo]];             }              nslog(@"url2:%@", url2);              nsurlrequest *requestobj = [nsurlrequest requestwithurl:url2];              [webview loadrequest:requestobj];              [[self view] addsubview:webview];          }     }  }  @catch (nsexception * e) {     nslog(@"exception: %@", e);     [self alertstatus:@"login failed." :@"login failed!" :0]; } }   -(void)webviewdidstartload:(uiwebview *)webview{ nslog(@"webviewdidstartload"); [self.view addsubview:self.indicator];  alert.hidden = no;   }   - (void) webviewdidfinishload:(uiwebview *)webview {  nslog(@"webviewdidfinishload"); [self.indicator removefromsuperview]; [self.alert dismisswithclickedbuttonindex:1 animated:no] ;  }  - (ibaction)backgroundclick:(id)sender { [txtsecurecode resignfirstresponder]; [organizationcode resignfirstresponder]; } @end 

untill content in webview displays, loading image displaying , working good. content of webview not editable , remaining static think used 'web view.hidden = yes'. when comment alert method , run content of webview editable , working required. need load content of url after loading image stops loading. can me solve issue... in advance.

i suggest show activity indicator viewcontroller having webview , implement webview delegate methods

- (void)webviewdidstartload:(uiwebview *)webview {     [actvityindicator startanimating]; } 

and

- (void)webviewdidfinishload:(uiwebview *)webview {     [actvityindicator stopanimating]; } 

this keep webview interactive , show indicator till page loads completely


Comments