谈谈 oc原生和跳转h5 页面 来回切换的功能

1.当我跳转到view的时候 <UIWebViewDelegate>

#pragma mark -

#pragma mark - UIWebViewDelegate

- (void)webViewDidStartLoad:(UIWebView *)webView {

    //      self.tabBarController.tabBar.hidden=YES;

    NSLog(@"%s", __FUNCTION__);

}

 

- (void)webViewDidFinishLoad:(UIWebView *)webView {

    NSLog(@"%s", __FUNCTION__);

}

 

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

    NSLog(@"%s", __FUNCTION__);

}

 

- (void)buildingUI {

    self.view.backgroundColor = [UIColor whiteColor];

 

}

//如果是H5页面里面自带的返回按钮处理如下:

#pragma mark - webViewDelegate

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

    NSString * requestString = [[request URL] absoluteString];

    requestString = [requestString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    //获取H5页面里面按钮的操作方法,根据这个进行判断返回是内部的还是push的上一级页面

    if ([requestString hasPrefix:@"http://h5app.shugenpay.com/p/H5app/index.web"]) {

        [self.navigationController popViewControllerAnimated:YES];

    }else{

    }

    return YES;

}

 

- (UIWebView *)webView {

    if (!_webView) {

        _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.view.bounds.size.height+50)];

        _webView.delegate = self;

        [self.view addSubview:_webView];

    }

    return _webView;

}

当我调回我的原生的时候,我用了web的代理方法去解决这个问题

 

posted on 2017-06-29 17:21  super-Main  阅读(247)  评论(0)    收藏  举报