iphone - IOS UIWebView Crashes -


firstly i'm new obj-c, come php javascrript background. previous apps have been in phonegap. problem i'm facing need load webview apple keeps rejecting because watchdog timer kicks in on ios 6. tried adding webview secondary thread spinners on main thread error.

tried obtain web lock thread other main thread or web thread. may result of calling uikit secondary thread. crashing now...  

here code, if can point me in right direction i'd appreciate :)

- (void)viewdidload  { [super viewdidload]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{     if (dispatch_get_current_queue() == dispatch_get_main_queue()) {         nslog(@"webview on main thread!");     } else {         nslog(@"webview not on main thread!");     }     nsstring *fullurl = @"http://www.example.com";     nsurl *url = [nsurl urlwithstring: fullurl];     nsurlrequest *requestobj = [nsurlrequest requestwithurl:url];     _mywebview.backgroundcolor = [uicolor graycolor];     _mywebview.opaque=no;     [_mywebview loadrequest:requestobj];     _mywebview.scalespagetofit = yes; }); }  - (void) webviewdidstartload:(uiwebview *)webview { dispatch_async(dispatch_get_main_queue(), ^{     if (dispatch_get_current_queue() == dispatch_get_main_queue()) {         nslog(@"spinner start on main thread!");     } else {         nslog(@"spinner start not on main thread!");     }     [_myactivity startanimating]; });   }  - (void) webviewdidfinishload:(uiwebview *)webview { dispatch_async(dispatch_get_main_queue(), ^{     if (dispatch_get_current_queue() == dispatch_get_main_queue()) {         nslog(@"spinner stop on main thread!");     } else {         nslog(@"spinner stop not on main thread!");     }     [_myactivity stopanimating]; });         }     @end 

thanks!

i think use it...

 -(void) viewdidload {      [super viewdidload];      // additional setup after loading view nib.      nslog(@"%@",selection);     nsurl *url = [nsurl urlwithstring:@"http://www.example.com"];      nsurlrequest *requestobj = [nsurlrequest requestwithurl:url];      [webview loadrequest:requestobj];       }   -(void) showalertforwait{  uiactivityindicatorview *activity= [[uiactivityindicatorview alloc] initwithframe: cgrectmake(125, 80, 30, 30)];      activity.activityindicatorviewstyle = uiactivityindicatorviewstylewhitelarge;      alert= [[uialertview alloc]initwithtitle:@"process"                                   message:@"please wait ..."                                  delegate: self                         cancelbuttontitle: nil                         otherbuttontitles: nil];      [alert addsubview:activity];     [activity startanimating];     [alert show];    }  -(void)webviewdidstartload:(uiwebview *)webview {    [self showalertforwait];       }  -(void)webviewdidfinishload:(uiwebview *)webview {      [alert dismisswithclickedbuttonindex: 0                              animated: yes];          }   -(void)webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error{      nslog(@"error");     [alert dismisswithclickedbuttonindex: 0                              animated: yes];    } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -