yanerweb
V2EX  ›  Xcode

求 iOS 上混合模式 APP 的开发经验?如原生 OC 和 WebViewer 的交互经验?案例类似美团、猫眼等

  •  
  •   yanerweb · Dec 24, 2015 · 5618 views
    This topic created in 3792 days ago, the information mentioned may be changed or developed.

    常见的 美团、猫眼、饿了么 这样的 iOS APP ,因为业务 UI 呈现变化很快,所以大量的 UI 用的是 WebViewer 呈现网页。
    我理解的结构应该是,底部的主 NavBar 是原生的 OC 实现,分享,登录 也是 OC 原生的,
    而 主要的内容展示流、活动流、 是采用 WebViewer 嵌入了 HTML5 的页面,
    然后根据需求,与 OC 的其他 UI 进行交互,
    我是一个菜鸟,现在也准备开发类似的 APP ,希望能听取大家关于此类 APP 开发的经验,谢谢。

    6 replies    2015-12-25 16:30:43 +08:00
    pupboss
        1
    pupboss  
       Dec 24, 2015
    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {

    NSURL *url = request.URL;

    if ([url isEqual:[NSURL URLWithString:@"xxxxxxx"]]) {

    [self performSegueWithIdentifier:@"xxxxxxx" sender:nil];
    return NO;
    }
    if ([url isEqual:[NSURL URLWithString:@"xxxxxxx"]]) {

    [self performSegueWithIdentifier:@"xxxxxxx" sender:nil];
    return NO;
    }
    }
    return YES;
    }
    LMkillme
        2
    LMkillme  
       Dec 24, 2015
    不需要兼容 iOS7 以下:用原生的 JavaScriptCore
    需要兼容:用 WebViewJavascriptBridge 这个库
    LMkillme
        3
    LMkillme  
       Dec 24, 2015   ❤️ 1
    帮人帮到底,慕课网有视频教程 http://www.imooc.com/view/92
    tuoxie007
        5
    tuoxie007  
       Dec 25, 2015 via iPhone   ❤️ 1
    javascriptwebviewbridge on github
    rayshen
        6
    rayshen  
       Dec 25, 2015   ❤️ 1
    http://www.cnblogs.com/rayshen/p/4560728.html
    分享下我之前写的博客
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   932 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 20:50 · PVG 04:50 · LAX 13:50 · JFK 16:50
    ♥ Do have faith in what you're doing.