ShannonChenCHN / iOSDevLevelingUp

A journey of leveling up iOS development skills and knowledge.
365 stars 105 forks source link

Web View 与 Hybrid #32

Open ShannonChenCHN opened 7 years ago

ShannonChenCHN commented 7 years ago
ShannonChenCHN commented 7 years ago

参考资料:

ShannonChenCHN commented 7 years ago

UIWebView 介绍和使用

1.API

属性:

@property (nullable, nonatomic, assign) id <UIWebViewDelegate> delegate;

@property (nonatomic, readonly, strong) UIScrollView *scrollView NS_AVAILABLE_IOS(5_0);
@property (nullable, nonatomic, readonly, strong) NSURLRequest *request;

@property (nonatomic, readonly, getter=canGoBack) BOOL canGoBack;
@property (nonatomic, readonly, getter=canGoForward) BOOL canGoForward;
@property (nonatomic, readonly, getter=isLoading) BOOL loading;

@property (nonatomic) BOOL scalesPageToFit;

@property (nonatomic) BOOL detectsPhoneNumbers NS_DEPRECATED_IOS(2_0, 3_0);
@property (nonatomic) UIDataDetectorTypes dataDetectorTypes NS_AVAILABLE_IOS(3_0);

@property (nonatomic) BOOL allowsInlineMediaPlayback NS_AVAILABLE_IOS(4_0); 
@property (nonatomic) BOOL mediaPlaybackRequiresUserAction NS_AVAILABLE_IOS(4_0); 

@property (nonatomic) BOOL mediaPlaybackAllowsAirPlay NS_AVAILABLE_IOS(5_0); 

@property (nonatomic) BOOL suppressesIncrementalRendering NS_AVAILABLE_IOS(6_0);

@property (nonatomic) BOOL keyboardDisplayRequiresUserAction NS_AVAILABLE_IOS(6_0); 

@property (nonatomic) UIWebPaginationMode paginationMode NS_AVAILABLE_IOS(7_0);
@property (nonatomic) UIWebPaginationBreakingMode paginationBreakingMode NS_AVAILABLE_IOS(7_0);
@property (nonatomic) CGFloat pageLength NS_AVAILABLE_IOS(7_0);
@property (nonatomic) CGFloat gapBetweenPages NS_AVAILABLE_IOS(7_0);
@property (nonatomic, readonly) NSUInteger pageCount NS_AVAILABLE_IOS(7_0);

@property (nonatomic) BOOL allowsPictureInPictureMediaPlayback NS_AVAILABLE_IOS(9_0);
@property (nonatomic) BOOL allowsLinkPreview 

方法:

- (void)loadRequest:(NSURLRequest *)request;
- (void)loadHTMLString:(NSString *)string baseURL:(nullable NSURL *)baseURL;
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName baseURL:(NSURL *)baseURL;

- (void)reload;
- (void)stopLoading;

- (void)goBack;
- (void)goForward;

- (nullable NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;

2. webViewDidFinishLoad 方法的一些问题

2.1 webViewDidFinishLoad 什么时候被调用

2.2 为什么会出现 loadRequest 一次,webViewDidFinishLoad 却被多次调用的情况?

ShannonChenCHN commented 7 years ago

WKWebView 的介绍和使用

1.背景介绍

6.与 UIWebView 的性能比较

7.缺陷

8.兼容 iOS7 的封装,以及 WKWebView/UIWebView 相关开源代码

ShannonChenCHN commented 7 years ago

常见问题

1.如何调试 UIWebView 和 WKWebView

1.1 Safari

1.2 查看 h5 中的请求

1.3 调试工具

ShannonChenCHN commented 7 years ago

豆瓣的混合开发框架 -- Rexxar

1.混合开发

2.Rexxar 的背景

3.Rexxar 的介绍

4.Rexxar 的问题

ShannonChenCHN commented 7 years ago

《唐巧:基于 UIWebView 的混合编程》

一、混合编程(Hybrid)简介

实际应用中,基于 UIWebView 的界面的共同特点: 1.排版复杂。 2.界面的变化需求频繁。 3.界面对用户的交互需求不复杂。

二、使用模板引擎渲染 HTML 界面

1.HTML 片段的基本处理 相关 API:

- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL

HTML 片段格式化:

- (NSString *)demoFormatWithName:(NSString *)name value:(NSString *)value {
    NSString *html =
    @"<HTML>"
    "<HEAD>"
    "</HEAD>"
    "<BODY>"
    "<H1>%@</H1>"
    "<p>%@</p>"
    "</BODY>"
    "</HTML>";

    NSString *content = [NSString stringWithFormat:html, name, value];
    return content;
}

三、Objective-C 语言和 JavaScript 语言相互调用

四、如何传递参数

五、同步和异步

六、注意事项

1.线程阻塞问题
2.主线程的问题
3.键盘控制
4.CommonJS 规范

七、使用 Safari 进行调试

ShannonChenCHN commented 7 years ago

Hybrid 改进计划

当前要解决的问题:

期望的目标:

工作点:

ShannonChenCHN commented 6 years ago

长按保存 UIWebView 中的图片

参考