1.cmd+k 键盘toggle 2.模拟器的handware设置ios键盘 3.设置textfield的return类型为搜索 k.returnKeyType=UIReturnKeyType.search 4.uiswitch @IBOutlet weak var rightswitch: UISwitch! @IBOutlet weak var leftswitch: UISwitch! @IBAction func switchValueChange(_ sender: Any) { var s = sender as! UISwitch var setting = s.isOn leftswitch.setOn(setting, animated: true) rightswitch.setOn(setting, animated: true) } 5. UISegmentedControl @IBAction func touchDown(_ sender: Any) { let seg = sender as! UISegmentedControl print("段:",seg.selectedSegmentIndex) } 6.UISlider @IBAction func sliderValueChange(_ sender: Any) { var slider = sender as! UISlider let p = Int(slider.value) print(p) } 7. 加载html网页,可以实现代理方法 var webView:UIWebView! override func viewDidLoad() { super.viewDidLoad() self.webView = UIWebView.init(frame: self.view.bounds) self.view.addSubview(self.webView) let url:NSURL = NSURL.init(string: "https://www.baidu.com")! let req = NSURLRequest.init(url: url as URL) webView.loadRequest(req as URLRequest) } 8. IOS默认弹窗 @IBAction func click(_ sender: Any) { let a = UIAlertController.init(title: "title", message: "msg", preferredStyle: .alert) let noAction = UIAlertAction.init(title: "取消", style: .cancel) { (p) in print("取消啦") } let yesAction = UIAlertAction.init(title: "确认", style: .default) { (p) in print("ok啦") } //假如只有一个的话,添加一个就可以了 a.addAction(noAction) a.addAction(yesAction) present(a, animated: true) { print("点了某个了") } } 9.UINavigationController中有是个stack ,可以push一些 vc,有3个子的东西,分别是navigationBar(顶部导航条)和navigationItem(顶部导航条的内容)和title 在子视图中可以通过navigationController访问导航控制器,同时可以通过navigationController的childViewControllers获得当前栈中所有的子视图(注意每一个出栈的子视图都会被销毁) 10.swift.sqlite http://blog.csdn.net/sps900608/article/details/51483738 11.swift 桥接文件 http://blog.csdn.net/qq_29284809/article/details/50977432