Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WKWebView 能否添加支持? #81

Closed
fuchenxi opened this issue Dec 7, 2020 · 7 comments
Closed

WKWebView 能否添加支持? #81

fuchenxi opened this issue Dec 7, 2020 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@fuchenxi
Copy link

fuchenxi commented Dec 7, 2020

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@HeathWang
Copy link
Owner

你想要如何支持?

@fuchenxi
Copy link
Author

fuchenxi commented Dec 8, 2020

现在 panScrollView 返回webView.scrollView 之后 scrollView 不可滑动了

@HeathWang
Copy link
Owner

现在 panScrollView 返回webView.scrollView 之后 scrollView 不可滑动了

估计是web view contentSize问题,可以试下在webview加载完成后调用一下reload api,重新布局下

@HeathWang
Copy link
Owner

#import "HWTestWebViewController.h"
#import <HWPanModal/HWPanModal.h>
#import <WebKit/WebKit.h>


@interface HWTestWebViewController () <HWPanModalPresentable, WKNavigationDelegate>

@property (nonatomic, strong) WKWebView *webview;

@end

@implementation HWTestWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.webview = [[WKWebView alloc] initWithFrame:self.view.bounds];
    self.webview.navigationDelegate  = self;
    [self.view addSubview:self.webview];
    
    [self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.baidu.com"]]];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.webview.frame = self.view.bounds;
}

#pragma mark - WKNavigationDelegate

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    NSLog(@"%s", __PRETTY_FUNCTION__);
    [self hw_panModalSetNeedsLayoutUpdate];
}

#pragma mark - HWPanModalPresentable

- (UIScrollView *)panScrollable {
    return self.webview.scrollView;
}

- (PanModalHeight)longFormHeight {
    return PanModalHeightMake(PanModalHeightTypeMaxTopInset, 64);
}

@end

@HeathWang
Copy link
Owner

对于js加载完数据,contentSize变化的,同样需要调用hw_panModalSetNeedsLayoutUpdate

@HeathWang HeathWang added the help wanted Extra attention is needed label Dec 9, 2020
@HeathWang HeathWang pinned this issue Dec 9, 2020
@mlch911
Copy link
Contributor

mlch911 commented Mar 31, 2022

这样做其实不太好,应该给webscrollView加一个contentSizeKVO,在每次contentSize变化的时候调用hw_panModalSetNeedsLayoutUpdate

@HeathWang
Copy link
Owner

这样做其实不太好,应该给webscrollView加一个contentSizeKVO,在每次contentSize变化的时候调用hw_panModalSetNeedsLayoutUpdate

这样也可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants