0
我最近放弃了iOS 5对我的应用程序的支持,并使用UIRefreshControl进行了操作。我没有完全建立和完美工作。我的目标是让它刷新,如果它在我网站上的当前网址,或者它在另一个网站上,比如youtube,请重新加载并刷新到我的网站。合理?根据当前URL使用UIRefreshControl刷新
到目前为止,我尝试过这样做没有成功。我去了YouTube,NSLog把它当作我现在的网站。我很困惑,因为它显然不是。
任何帮助,将不胜感激。
-(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");
}
}