我正在创建一个使用UIWebView显示计划的应用。我添加了一个按钮,单击该按钮可从Web服务器下载更新的计划。我的尝试是当使用[iPadscheduleView reload]时,使该按钮的动作也刷新UIWebView;它没有任何效果。
我的viewDidLoad
-(void)viewDidLoad {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *fullPath = [[paths lastObject] stringByAppendingPathComponent:@"schedule.html"];
NSURL *url = [NSURL fileURLWithPath:fullPath];
[iPadscheduleView loadRequest:[NSURLRequest requestWithURL: url]];
[super viewDidLoad];
}
我的IBAction按钮
-(IBAction)synctheschedule {
NSData *fetchedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.elitespark.com/schedule.html"]];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"schedule.html"];
[fetchedData writeToFile:filePath atomically:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Popup" message:@"The schedule has been synced with the server." delegate:nil cancelButtonTitle:@"Refresh" otherButtonTitles:nil];
[alert show];
[alert release];
[iPadscheduleView reload];
}
非常感谢任何帮助。感谢