Swift 实践之UIWebView】的更多相关文章

1.选中工程,点击右键,New File>在iOS下选中Othe>Empty,生成一个.js的脚本文件,将代码粘贴过去保存; var script = document.createElement('script'); script.type = 'text/javascript'; script.text = ' function signin_go(){ location.href="ios:@signin_go"; } '; document.getElementsB…
原理: 1.JS调用OC 每次webview执行跳转时都会被iOS给拦截,执行下面函数获得系统允许. 因此可以根据跳转信息转给系统,执行相应功能,比如打开相册等. // 网页中的每一个请求都会被触发 -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 2.OC调用JS…
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // 选择空间的创建, 并监听控件的选择值 let items = ["选项1","选项2",UIImage.init(named: "1.png")!] as [Any] let segment = UISegmentedControl.i…
这两个用法比较简单: 具体代码如下: 一.UISegmentedControl 1.UISegmentedControl的声明 var segment = UISegmentedControl() 2.UISegmentedControl的创建 func initSegment() { segment = UISegmentedControl(items:["one", "two", "three", "four"]) seg…
import UIKit class ViewController: UIViewController ,UIScrollViewDelegate{ override func viewDidLoad() { super.viewDidLoad() let scrollView = UIScrollView.init() scrollView.frame = self.view.bounds let imageView = UIImageView.init(image: UIImage.init…
import UIKit class ViewController: UIViewController { var stepper: UIStepper! var label: UILabel! override func viewDidLoad() { super.viewDidLoad() // 微调器 (UIStepper) 控件包含两个按钮 + ,-, 让使用者可以依照自己的喜欢做数值上的调整 stepper = UIStepper.init() stepper.center = sel…
import UIKit class ViewController: UIViewController , UIPickerViewDelegate,UIPickerViewDataSource{ var pickerView: UIPickerView! override func viewDidLoad() { super.viewDidLoad() pickerView = UIPickerView() pickerView.frame = CGRect.init(x: 0, y: 0,…
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let slider = UISlider.init(frame: CGRect.init(x: 0, y: 0, width: 300, height: 50)) slider.center = self.view.center slider.minimumValue = 0 slider…
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let progressView = UIProgressView(progressViewStyle: .default) progressView.center = self.view.center progressView.progress = 0.5 // 默认 50% self.v…
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let imageView = UIImageView.init(image: UIImage.init(named: "1")) imageView.frame = CGRect(x: 10, y: 30, width: 300, height: 150) self.view.a…