내가 IOS 프로그래밍에 새로운 해요,하지만 난 그것이 스위프트 3touchUpInside 이벤트가
class BottomMenu : NSObject{
//Container view
var bottomView: UIView!
//Button
var buttonContents : UIButton!
init(bottomView : UIView) {
super.init()
self.bottomView = bottomView
buttonContents = UIButton(frame: getFrame(index: 0))
buttonContents.backgroundColor = UIColor.blue //To see where to click on the screen
bottomView.addSubview(buttonContents)
buttonContents.addTarget(self, action: #selector(onClick), for: .touchUpInside)
}
func getFrame(index : CGFloat!) -> CGRect{
let screenW = UIScreen.main.bounds.width
return CGRect(x: (screenW/3) * index,
y: 0,
width: screenW/3,
height: self.bottomView.frame.size.height)
}
func onClick(sender: UIButton!){
NSLog("click")
}
}
의 를 작동하지 않는 이유는 어떤 생각을하지 않아도 이상하게도 동일한 코드가 다른 클래스에서 작동 트리거되지
let bottomMenu = BottomMenu(bottomView: bottomNavBarContainer)
는 그래서, "클릭"결코 기록하지
빠른 버전을 태그에 추가하십시오. – shallowThought
예, 죄송합니다. Swift입니다. – user2976267