Я пытаюсь передать свое приложение с Objective-C на Swift, но у меня есть некоторые проблемы с моим действием UIButton
, которое никогда не вызывается.Действие UIButton не работает
UIButton
декларация (с учетом колонтитула):
let footerView = UIView.init(frame: CGRectMake(0, 0, self.view.frame.size.width, 140))
let acceptButton = UIButton(type: .Custom)
acceptButton.userInteractionEnabled = true
acceptButton.setTitle("Accepter", forState: .Normal)
acceptButton.addTarget(self, action: "acceptRequest:", forControlEvents: .TouchUpInside)
acceptButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
acceptButton.titleLabel!.font = UIFont(name: "AvenirNext-Medium", size:16.0)
acceptButton.frame = CGRectMake((self.view.frame.size.width/2)-115, 35,230, 40)
acceptButton.layer.cornerRadius = 4
acceptButton.layer.borderWidth = 1
acceptButton.layer.borderColor = UIColor.customGreen().CGColor
acceptButton.layer.backgroundColor = UIColor.customGreen().CGColor
footerView.addSubview(acceptButton)
возвращение footerView;
Действие:
func acceptRequest(sender:UIButton!) {
print("2")
}
я пропустил что-то с Swift?
acceptRequest находится в том же классе, что и footerView справа? –
что такое разделFooterHeight? правильно настроен? – jay
Можете ли вы добавить код ?. Какая ошибка вы получаете? Вы видите кнопку? – HyLian