ios - Refresh using UIRefreshControl depending on current URL -
i have dropped ios 5 support app , went using uirefreshcontrol. i't set , working perfectly. goal thread have refresh if current url in website, or if it's on site youtube, have reload , refresh site. make sense?
so far have tried doing without success. went youtube, , nslog showed current site. confused it's not.
any appreciated.
-(void)handlerefresh:(uirefreshcontrol *)refresh { nsstring *string = @"mysite.com"; if ([string rangeofstring:@"mysite"].location == nsnotfound) { // reload data nsstring *fullurl = @"http://www.mysite.com/"; nsurl *url = [nsurl urlwithstring:fullurl]; nsurlrequest *requestobj = [nsurlrequest requestwithurl:url]; [webview loadrequest:requestobj]; [(uiwebview *)[self.view viewwithtag:999] reload]; [overlay postmessage:@"reloading" duration:1 animated:yes]; //set title while refreshing refresh.attributedtitle = [[nsattributedstring alloc]initwithstring:@"refreshing view"]; //set date , time of refreshing nsdateformatter *formatteddate = [[nsdateformatter alloc]init]; [formatteddate setdateformat:@"mmm d, h:mm a"]; nsstring *lastupdated = [nsstring stringwithformat:@"last updated on %@",[formatteddate stringfromdate:[nsdate date]]]; refresh.attributedtitle = [[nsattributedstring alloc]initwithstring:lastupdated]; lastupdated:[uicolor colorwithred:(87.0/255.0) green:(108.0/255.0) blue:(137.0/255.0) alpha:1.0]; //end refreshing [refresh endrefreshing]; nslog(@"string not contain mysite"); } else { // reload data nsstring *fullurl = webview.request.url.absolutestring; nsurl *url = [nsurl urlwithstring:fullurl]; nsurlrequest *requestobj = [nsurlrequest requestwithurl:url]; [webview loadrequest:requestobj]; [(uiwebview *)[self.view viewwithtag:999] reload]; [overlay postmessage:@"reloading" duration:1 animated:yes]; //set title while refreshing refresh.attributedtitle = [[nsattributedstring alloc]initwithstring:@"refreshing view"]; //set date , time of refreshing nsdateformatter *formatteddate = [[nsdateformatter alloc]init]; [formatteddate setdateformat:@"mmm d, h:mm a"]; nsstring *lastupdate = [nsstring stringwithformat:@"last updated on %@",[formatteddate stringfromdate:[nsdate date]]]; refresh.attributedtitle = [[nsattributedstring alloc]initwithstring:lastupdate]; lastupdate:[uicolor colorwithred:(87.0/255.0) green:(108.0/255.0) blue:(137.0/255.0) alpha:1.0]; //end refreshing [refresh endrefreshing]; nslog(@"string contains mysite"); } }
think got it.
literally had change top: nsstring *string = webview.request.url.absolutestring;
so far good. if have other issues ill bump thread.
Comments
Post a Comment