adsense728x90


UIButton에 target action을 swift code로 추가하기 iOS


"...:" :를 빼먹지 말기.



  • import UIKit
  • class MyViewController: UIViewController {
  • let myButton = UIButton(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
  • init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
  • super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
  • myButton.addTarget(self, action: "tappedButton:", forControlEvents: .TouchUpInside)
  • }
  • func tappedButton(sender: UIButton!) {
  • println("tapped button")
  • }
  • }



덧글

댓글 입력 영역