我想刷新一個UIWebView,每當我的應用程序來到前臺。我真正在ViewController.m中有一個檢查互聯網訪問(hasInternet)和viewDidLoad的方法。如何在應用程序進入前臺時刷新UIWebView?
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize webview;
-(BOOL)hasInternet{
Reachability *reach = [Reachability reachabilityWithHostName:@"www.google.com"];
NetworkStatus internetStats = [reach currentReachabilityStatus];
if (internetStats == NotReachable) {
UIAlertView *alertOne = [[UIAlertView alloc] initWithTitle:@"You're not connected to the internet." message:@"Please connect to the internet and restart the app." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alertOne show];
}
return YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self hasInternet];
[webView loadRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://warm-chamber-7399.herokuapp.com/"]] ];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
有關如何啓用此功能的任何建議?它是在AppDelegate中進行還是在ViewController.m中創建另一個方法?
只有使用[tag:Xcode]標籤才能瞭解關於IDE本身的問題。謝謝! – Undo 2013-04-07 01:42:28