타겟을 UIButton에 추가하려고하지만 중첩 된 함수를 액션으로 사용할 때 오류가 발생합니다. 나는 제거해야하기 때문에 나는 'remove' 기능을 필요`UIButton`에 대한 액션으로 중첩 된 함수 사용
warning: No method declared with Objective-C selector 'remove'.
'createAddView'function에 중첩되는 :
func createAddView() {
let addButton = UIButton()
func remove(sender: UIButton) {
print("Remove")
}
addButton.addTarget(self, action: #selector(remove(sender:)), for: .touchUpInside)
}
그것은 나에게이 경고를주고하는 것은 다음과 같습니다
내 코드입니다 'createAddView '함수에서 생성되는 다른 UIView를 페이드 아웃합니다.누구든지이 작업을 수행 할 수 있습니다.
타겟으로 중첩 된 함수를 사용할 수 없습니다 : http://stackoverflow.com/questions/29802074/nested-function-selector-in-swift-for-testing –
func remove (보낸 사람 : UIButton)를 외부로 이동하십시오. 귀하의'createAddView()'및 시도? – Joe