I have recently dropped iOS 5 support for my app and went with using UIRefreshControl. I't all set up and working perfectly. My goal from this thread is to have it refresh if its a current url in my website, or if it's on another site like youtube, have it reload and refresh back to my site. Make sense?
So far I have tried doing this without success. I went to YouTube, and the NSLog showed it as my current site. Which I am confused about as it's clearly not.
Any help would be appreciated.
-(void)handleRefresh:(UIRefreshControl *)refresh {
NSString *string = @"MySite.com";
if ([string rangeOfString:@"MySite"].location == NSNotFound) {
// Reload my 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 the title while refreshing
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing the View"];
//set the date and 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 the refreshing
[refresh endRefreshing];
NSLog(@"String does not contain MySite");
} else {
// Reload my 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 the title while refreshing
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing the View"];
//set the date and 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 the refreshing
[refresh endRefreshing];
NSLog(@"String contains MySite");
}
}
Think I got it.
Literally had to change the top: NSString *string = webView.request.URL.absoluteString;
So far so good. If I have any other issues with it ill bump this thread.