Giter Site home page Giter Site logo

dequan1331 / hybridpagekit Goto Github PK

View Code? Open in Web Editor NEW
1.2K 17.0 186.0 38.92 MB

A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App.

License: MIT License

Objective-C 99.80% Ruby 0.20%
hybrid wkwebview scrollview newsapp reuse

hybridpagekit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hybridpagekit's Issues

关于使用 wkwebview 和 LocalWebServer的思路

不是很清楚,大厂都是怎么使用 LocalWebServer 来支持离线包的,下面是我想的一些思路:
1、把本地服务器的地址放在请求头里,然后服务器端渲染,如果是来自app的请求,把所有src的host改成 app 本地服务的localhost。只是这种方式也对后续异步渲染和懒加载JS就不太好支持了。
2、服务器端渲染返回 src='customScheme://',然后 urlprotocol 这拦截 customScheme 的请求,也不会引起 http ajax 丢失 body。

自己也觉得这两种方式,实际上都需要服务器端配合,另外还需要H5业务方去配合支持后续的src的改动。
成本上是有点高的,如果是不要服务器端配合,那至少也是需要 H5业务放配合把所有加载图片和脚本的地方,都要使用JS动态借助Native能力去加载,可是这样会破坏H5的原有结构。

能请教下还有什么更好的思路吗?

UIView上面加载WebView

在UIView上面加载WebView时,native + webView, HPKPageHandler 需要怎么初始化, 在ViewController是```

  • (void)configWithViewController:(__kindof UIViewController *)viewController
    componentsControllers:(NSArray<HPKController *> *)componentsControllers;

请问如何注入js方法到webview

请问如何注入js方法到webview,在初始化HPKWebView的时候没有添加UserContentController的地方,希望能指导一下。谢谢

懒加载图片的时候注入加载图片的js

[self.componentHandler.webView evaluateJavaScript:@"loadImages()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
if (error) {
NSLog(@"错误:------>%@", error);
}
}];

打印:
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=22, WKJavaScriptExceptionMessage=ReferenceError: Can't find variable: $, WKJavaScriptExceptionColumnNumber=16, WKJavaScriptExceptionSourceURL=about:blank, NSLocalizedDescription=A JavaScript exception occurred}

有两个框架相关的问题咨询一下

1、目前我们是通过一个本地html和js去展示页面。在页面load本地页面时调用初始化js对象的方法,在APP启动以后第一次加载是正常的,后续加载页面就不能正常展示内容。如果调用clearCache或者[[HPKPageManager sharedInstance] clearAllReusableWebViews];方法才能正常展示出来。请问是否有比较好的解决办法。
2、在APP第一次加载webview的时候很慢,请问是否可以在展示webview之前就提前加载。

在默认缓存策略下,重用后的webView会忽略304缓存,每次都会重新获取主html

默认缓存策略
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];

实际复现步骤:
1、打开一个支持协商缓存的h5
2、退出当前h5,然后重新进入,会发现有重新请求h5主html,状态码是200

期望结果
1、打开一个支持协商缓存的h5
2、退出当前h5,然后重新进入,会发现有重新请求h5主html,状态码是304

Only webView 有bug

双击时当前cell滑动到屏幕中间,但是再滑动列表时,会出现弹跳

无法拦截本地js/html文件

我使用 wkwebview + NSURLProtocol 尝试拦截本地的html/js 文件以及相应的请求,
但是并没有触发 + (BOOL)canInitWithRequest:(NSURLRequest *)request 方法, 这个方法在UIWebView 里面是会触发的 ,这种情况该如何修改支持 本地(file:// )的这种请求拦截

WKWebView 高度问题

现在还是 WKWebView 计算有问题,如果我在外部想用和前端约定好的方法获取内容高度,请问需要如何处理呢? NSString *jsString = [NSString stringWithFormat:@"document.documentElement.offsetHeight * %d / document.documentElement.clientWidth",(int)_defaultWebView.bounds.size.width];
这个方法获取的高度时对时不对,原因可能是我这里css js 里的一些样式问题导致的,我们这里定义了

后台返回的html字符串
然后通过
"function getMainHeight() {"
"var main = document.getElementById('main');"
"return main.offsetHeight;"
"}"
获取高度是没问题,请问如何自己外部设置wk 高度吗

标题不能自适应高度

作者你好,在你的demo中 articleContent.txt,内 给标题字符串增加了很多字符,但是TitleView的TitleLabel依然是一行 设置了.numberOfLines=0; 也没有用,我也理解sizeToFit 的意思,但事实就是无法自适应高度

native view渲染方式

html计算实际站位的native view的过程在js里面是不是很消耗性能,能不能通过类似yoga之类的布局引擎去优化?

进入界面后定位到指定的Component

请教一个问题
进入界面后定位到指定的Component
看到 HPKPageHandler有如下接口
(void)scrollToComponentView:(HPKView *)elementView atOffset:(CGFloat)offsetY animated:(BOOL)animated;
那要需要如何手动构建这个HPKView呢

支持识别白屏吗

在ios下由于内存不足,会将webkitwebview的web process卸载或者停止渲染,导致白屏问题,这个框架支持识别到这种白屏问题并且自动恢复吗

私有api会有审核风险么

- (void)_clearBackForwardList {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    SEL sel = NSSelectorFromString([NSString stringWithFormat:@"%@%@%@%@", @"_re", @"moveA", @"llIte", @"ms"]);
    if ([self.backForwardList respondsToSelector:sel]) {
        [self.backForwardList performSelector:sel];
    }
#pragma clang diagnostic pop
}

这段代码不会有审核风险么?

偶发:web展示不完整

第一次启动app,进入新闻详情页。web部分未展示完,再次进来又可以展示完整。
项目的demo更换数据也重现了这个问题。

无导航,iOS11 有问题

大神您好,页面无导航,页面最上面有空白。
在HPKAbstractViewController.m
_containerScrollView 的高度 把-64 去掉 并写下面代码
if (@available(iOS 11.0,*)) {
_containerScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else{
self.automaticallyAdjustsScrollViewInsets=NO;
}
布局就乱了 ,运营推广区和扩展阅读区跑到评论下面去了。

请教下没办法用Masonry布局吗

NestingWebViewController 我在demo里这个类,用Masonry写的_containerScrollView 布局显示不出来HPKWebView,改成frame 正常?是时机不对还是不支持Masonry呢

Make all comments in code English

I see your README has two language version: English and Chinese

But in code the comment almost Chinese, it's bad

Consider to use English to make all users around the world to read and participate the development

给TableView添加tableHeaderView和FooterView可能会导致计算出现问题

版本: 1.4.0
iOS版本: 13.4
复现:为您demo中的hotCommentView添加tableHeaderView 和FooterView
在HotCommentController.m中第57行插入

        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width , 5)];
        headerView.backgroundColor = UIColor.redColor;
        UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,  [UIScreen mainScreen].bounds.size.width , 5)];
        footerView.backgroundColor = UIColor.redColor;
        _hotCommentView.tableHeaderView = headerView;
        _hotCommentView.tableFooterView = footerView;

cocoapods failure

[!] Error installing HybridPageKit
[!] /usr/bin/git clone https://github.com/dequan1331/HybridPageKit.git /var/folders/rk/fy1x7s814x501kyzygn0tplc0000gn/T/d20180627-10811-12sd0h --template= --single-branch --depth 1 --branch 0.2

Cloning into '/var/folders/rk/fy1x7s814x501kyzygn0tplc0000gn/T/d20180627-10811-12sd0h'...
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

内存警告处理不友好

HPKWebView还在加载或者滚动显示中时,收到警告就直接给释放了,导致崩溃。
Cannot form weak reference to instance (0x10d013600) of class HPKWebView. It is possible that this object was over-released, or is in the process of deallocation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.