1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | __weak UIViewController *weakSelf=self; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ weakSelf.cacheVC=[MLCacheWebviewVC new]; weakSelf.cacheVC.url=[NSURL URLWithString:@"/index.html" relativeToURL:BASE_URL]; [weakSelf addChildViewController:weakSelf.cacheVC]; [self.tableView addSubview:weakSelf.cacheVC.view]; [weakSelf didMoveToParentViewController:weakSelf]; weakSelf.cacheVC.view.frame=CGRectMake(0,0,SCREEN_WIDTH,THE1PX_CONST); weakSelf.cacheVC.view.layer.opacity=0.01; NSURLRequest *request =[NSURLRequest requestWithURL:weakSelf.cacheVC.url]; [weakSelf.cacheVC.webView loadRequest:request]; [weakSelf.cacheVC.view setNeedsLayout]; [weakSelf.cacheVC.view layoutIfNeeded]; }); |