swift版本hello

來源:互聯網
上載者:User

標籤:

import UIKitclass ViewController: UIViewController {        @IBOutlet var button : UIButton?    //var alertView:UIAlertView?    override func viewDidLoad() {        super.viewDidLoad()        // Do any additional setup after loading the view, typically from a nib.    }    override func didReceiveMemoryWarning() {        super.didReceiveMemoryWarning()        // Dispose of any resources that can be recreated.    }    @IBAction func buttonPressed(sender : AnyObject) {        NSLog(button!.titleLabel!.text!)        var alertView : UIAlertView = UIAlertView(title: "Are You Sure", message: "Look This", delegate: nil, cancelButtonTitle: "OK")        alertView.show()    }}

串連有兩處:

1. 設計檢視和代碼聲明的按鈕定義的串連

2. 設計檢視的按鈕點擊事件和代碼的函數之間的串連

用輔助視圖同時開啟代碼檔案和視圖,按住control拖拽按鈕到代碼,可以分別建立相應的串連

swift版本hello

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.