当我的web viewDidLoad触发时,它正确设置了我的Web视图的起始URL并记录了“加载请求:http://xxxxxx.dev/login”。正如您所期望的那样。
从SidebarViewController调用loadRequestFromString时,webview不会更改为正确的URL。但是,由于NSLog,我可以看到它正在达到这一点,只是没有刷新URL“加载请求:http://xxxxxx.dev/this-is-the-url-that-should-load”。
SidebarViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSString *url = self.tableData[indexPath.row][@"url"];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
WebAppViewController *wvc = [[WebAppViewController alloc] initWithNibName:@"webappController" bundle:kNilOptions];
[wvc loadRequestFromString:url];
}
WebAppViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.delegate = self;
// Do any additional setup after loading the view, typically from a nib.
[self loadRequestFromString:@"http://xxxxxx.dev/login"];
}
.....
- (void)loadRequestFromString:(NSString*)urlString
{
self.webView.delegate = self;
NSLog(@"Load Request: %@", urlString);
NSString *properlyEscapedURL = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:properlyEscapedURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:urlRequest];
}