iOS WebView All In One

WKWebView / UIWebView

Swift Playground

//: A UIKit based Playground for presenting user interface

import PlaygroundSupport

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = ViewController()

//: A UIKit based Playground for presenting user interface

import UIKit
import PlaygroundSupport class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white let label = UILabel()
label.frame = CGRect(x: 150, y: 200, width: 200, height: 20)
label.text = "Hello World!"
label.textColor = .black view.addSubview(label)
self.view = view
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()

UIWebView 已废弃

https://developer.apple.com/documentation/uikit/uiwebview

class UIWebView : UIView

WKWebView

https://developer.apple.com/documentation/webkit/wkwebview

// iOS, Mac Catalyst

class WKWebView : UIView
// macOS
class WKWebView : NSView


Objective-C

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011210

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html

Objective-C 代码的文件扩展名

扩展名 内容类型

.h 头文件。头文件包含类,类型,函数和常数的声明。

.m 源代码文件。这是典型的源代码文件扩展名,可以包含 Objective-C 和 C 代码。

.mm 源代码文件。带有这种扩展名的源代码文件,除了可以包含Objective-C和C代码以外还可以包含C++代码。仅在你的Objective-C代码中确实需要使用C++类或者特性的时候才用这种扩展名。

https://www.runoob.com/w3cnote/objective-c-tutorial.html

https://www.runoob.com/ios/ios-objective-c.html

refs

https://github.com/paulirish/iOS-WebView-App



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


iOS WebView All In One的更多相关文章

  1. iOS Webview 实现修改javascript confirm 和 alert

    贴代码: @interface UIWebView (JavaScriptAlert) -(void) webView:(UIWebView *)sender runJavaScriptAlertPa ...

  2. ios webView 默认有缓存

    ios webview清除缓存. ios默认webview是有缓存的,所以不改变URL的话,刷新不了网页数据,或者像我这样写 NSMutableURLRequest *request = [NSMut ...

  3. iOS WebView 加载本地资源(图片,文件等)

    https://www.cnblogs.com/dhui69/p/5596917.html iOS WebView 加载本地资源(图片,文件等) NSString *path = [[NSBundle ...

  4. iOS webview加载时序和缓存问题总结

    iOS webView的加载时序 UIWebView加载顺序: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSU ...

  5. iOS webView 远程html加载本地资源

    昨天,一个朋友让我帮他在IOS上弄这样一件事情: webView 调用远程URL,并且让远程的web 通过自定义标签能实现内嵌本地的图片.js 或音频等. 比如:在服务器端 的html文件中 这样写到 ...

  6. iOS webview加载html自定义选项框选词

    项目要求:webview加载html网址,内容为英文文本,需要获取文本上的单词 这个是最终效果图: 思路是先实现自定义的选项框(不带系统选项)再获取到滑选的单词: 实现的步骤: 首先是替换掉系统长按出 ...

  7. ios webview 加载含有中文的URL网页显示白屏

    1. ios中的webview加载的URL不可以含有中文,解决办法说将中文字符转码, 如下: - (NSString *)URLEncodeString { NSCharacterSet *set = ...

  8. IOS webview iframe 宽度超出屏幕解决方案

    IOS 真机webview中,iframe 却不能很好地适应屏幕大小,总是超出屏幕尺寸,需要左右滚动才能看到完整页面. <div style="overflow: auto;-webk ...

  9. ios webview下footer部分fixed失效问题

    场景: 如下图所示,一个很正常的页面需求,footer固定在底部,中间为滚动内容区 然后footer的css一般是这样的 footer{ position:fixed; bottom:; left:; ...

随机推荐

  1. ldf和mdf文件怎么还原到sqlserver数据库

    1.把mdf文件和ldf文件拷贝到数据库的默认路径C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA里:2.在sq ...

  2. 浅析Redis与IO多路复用器原理

    为什么Redis使用多路复用I/O Redis 是跑在单线程中的,所有的操作都是按照顺序线性执行的,但是由于读写操作等待用户输入或输出都是阻塞的,所以 I/O 操作在一般情况下往往不能直接返回,这会导 ...

  3. On-the-fly Garbage Collection: an Exercise in Cooperation

    On-the-fly Garbage Collection: an Exercise in Cooperation - Microsoft Research https://www.microsoft ...

  4. (ETL)ETL架构师面试题(转载)

    1. What is a logical data mapping and what does it mean to the ETL team?什么是逻辑数据映射?它对ETL项目组的作用是什么? 答: ...

  5. 【LinuxShell】echo用法详解

    使用echo打印信息到终端 1 [Shell]echo "yz test" 2 yz test 3 [Shell]echo yz test 4 yz test 5 [Shell]e ...

  6. XV6学习(9)Lab cow: Copy-on-write fork

    代码在github上.总体来说如果理解了COW机制的话,这个实验的完成也没有很复杂. 这一个实验是要完成COW(copy on write)fork.在原始的XV6中,fork函数是通过直接对进程的地 ...

  7. Java三种IO模型和LinuxIO五种IO模型

    Java: https://github.com/Snailclimb/JavaGuide/blob/master/docs/java/BIO-NIO-AIO.md https://github.co ...

  8. cnpm安装依赖时报Error: Cannot find module 'core-js/modules/es6.regexp.constructor'

    解决方案:npm install core-js@2 大致猜测:cnpm掉包所致...

  9. Jumpserver-堡垒机

    Jumpserver-堡垒机 1.基于Docker搭建Jumpserver堡垒机 1.1 下载镜像 1.2 运行镜像 1.2.1 官网步骤-Docker快速启动 1.3 浏览器访问 2.Jumpser ...

  10. UI自动化实战进阶PO设计模式

    前言 经过前面的实战我们已经编写了几个测试用例,下面我们要用PO设计模式来调整我们的代码,让页面元素和测试业务进行分离,这样看起来直观而且后期的维护也方便. python有一个第三方的PO设计的库,既 ...