swift版本hello

import UIKit

class 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()
    }
}

鏈接有兩處:ide

1. 設計視圖和代碼聲明的按鈕定義的鏈接函數

2. 設計視圖的按鈕點擊事件和代碼的函數之間的鏈接設計

用輔助視圖同時打開代碼文件和視圖,按住control拖拽按鈕到代碼,能夠分別創建相應的鏈接code

相關文章
相關標籤/搜索