首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
Swift 实践之UIWebView
】的更多相关文章
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…
[iOS Hybrid实践:UIWebView中Html中用JS调用OC方法,OC执行JS代码]
原理: 1.JS调用OC 每次webview执行跳转时都会被iOS给拦截,执行下面函数获得系统允许. 因此可以根据跳转信息转给系统,执行相应功能,比如打开相册等. // 网页中的每一个请求都会被触发 -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 2.OC调用JS…
swift 实践- 08 -- UISegmentedControl
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…
swift - UISegmentedControl 和 UIWebView 的用法
这两个用法比较简单: 具体代码如下: 一.UISegmentedControl 1.UISegmentedControl的声明 var segment = UISegmentedControl() 2.UISegmentedControl的创建 func initSegment() { segment = UISegmentedControl(items:["one", "two", "three", "four"]) seg…
swift 实践- 14 -- UIScrollView
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…
swift 实践- 13 -- UIStepper
import UIKit class ViewController: UIViewController { var stepper: UIStepper! var label: UILabel! override func viewDidLoad() { super.viewDidLoad() // 微调器 (UIStepper) 控件包含两个按钮 + ,-, 让使用者可以依照自己的喜欢做数值上的调整 stepper = UIStepper.init() stepper.center = sel…
swift 实践- 12 -- UIPickerView
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,…
swift 实践- 11 -- UISlider
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…
swift 实践- 10 -- UIProgressView
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…
swift 实践- 09 -- UIImageVIew
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…