美文网首页
xcode编译的一些错误记录

xcode编译的一些错误记录

作者: 流星阁 | 来源:发表于2021-07-23 15:47 被阅读0次

1.真机运行时报Encountered an error communicating with IBxx-iOS.

一般情况下clean一下重新编译就好

2.web内展示富文本图片宽高适配问题

NSString *htmlP = [NSString stringWithFormat:@"<html> \n"
        "<head> \n"
        "<meta charset=\"UTF-8\"/><meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" name=\"viewport\">"
        "</head> \n"
        "<body style='word-wrap:break-word;'>"
        "<script type='text/javascript'>"
        "window.onload = function(){\n"
        "var $img = document.getElementsByTagName('img');\n"
        "if ($img && $img.length > 0)\n"
        "for(var p in  $img){\n"
        " $img[p].style.width = '100%%';\n"
        "$img[p].style.height ='auto'\n"
        "}\n"
        "}"
        "}"
        "</script><div id='content'>%@</div>"
        "</body>"
        "</html>",url];

3.web动态高度获取

// 页面加载完成之后调用 此方法会调用多次
- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
    __block CGFloat webViewHeight;
    //获取内容实际高度(像素)@"document.getElementById(\"content\").offsetHeight;"
    [webView evaluateJavaScript:@"document.getElementById(\"content\").offsetHeight" completionHandler:^(id _Nullable result,NSError * _Nullable error) {
        // 此处js字符串采用scrollHeight而不是offsetHeight是因为后者并获取不到高度,看参考资料说是对于加载html字符串的情况下使用后者可以(@"document.getElementById(\"content\").offsetHeight;"),但如果是和我一样直接加载原站内容使用前者更合适
        //获取页面高度,并重置webview的frame
        webViewHeight = [result doubleValue] + 20;
        if (self.contentSizeHeightBlock) {
            self.contentSizeHeightBlock(webViewHeight);
        }
    }];
}

4.error: Building for iOS Simulator, but the linked and embedded framework '***.framework' was buil...

修改项目配置里面的Validate Workspace为Yes,正常编译成功!
再次修改回NO,也会正常编译!
具体可参考 https://xcodebuildsettings.com 配置说明文档

相关文章

网友评论

      本文标题:xcode编译的一些错误记录

      本文链接:https://www.haomeiwen.com/subject/mmcpmltx.html