2015-09-14 63 views
0

我有兩個帶有UIWebViews場景的視圖控制器。主要的MainViewController應該調用第二個,稱爲ViewController,並在用戶使用PostPicPopUp鏈接到它時調出該場景。 在MainViewController我:在shouldStartLoadWithRequest中調用視圖控制器

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 

    NSURL *urL=request.URL; 
    NSString *urlStr=[urL absoluteString]; 
    //NSLog(@"URLL %@",urlStr); 

    if ([urlStr rangeOfString:@"PostPicPopUp"].location == NSNotFound) { 
     return YES; 
    } else { 
     return NO; 
    } 
} 

所以我需要你的代碼之前

return YES 

回答

0

您可以使用下面的代碼做打電話給你的視圖手動控制器:

// Objective-C 
ViewController *controller = [[ViewController alloc] init];  
[self controller animated:YES completion:nil]; 

// Using storyboard 
ViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"MyViewControllerIdentifier"]; 
[self presentViewController:controller animated:YES completion:nil]; 
相關問題