弹出视图上的按钮不起作用

时间:2015-04-03 21:19:01

标签: ios swift

我试图在自定义弹出视图中创建一个按钮。但是创建的按钮无法识别其动作。

func createPopUp(){
    view.userInteractionEnabled = false
    scrollerView.userInteractionEnabled = false
    var screenSize:CGRect = UIScreen.mainScreen().bounds
    var screenHeight = screenSize.height
    var screenWidth = screenSize.width

    var popUpView : UIImageView
    popUpView  = UIImageView(frame:CGRectMake(0, 0, 530, 150));
    popUpView.center = CGPointMake(screenWidth/2,screenHeight/2)
    popUpView.backgroundColor = UIColor.whiteColor()
    popUpView.tag = 81
    self.view.addSubview(popUpView)

    var vazgecButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
    vazgecButton.frame = CGRectMake(0, 0, 265, 60)
    vazgecButton.center = CGPointMake(250, 550)
    vazgecButton.setTitle("Vazgeç", forState: .Normal)
    vazgecButton.tag = 79
    vazgecButton.addTarget(self, action: "closePopUpView:", forControlEvents: UIControlEvents.TouchUpInside)
    self.view.addSubview(vazgecButton)
}

首先,我禁用了视图和我的scrollerView的用户interacton。然后我创建了一个弹出视图的图像视图,以保持我的按钮。既不添加popUpView也不查看工作。

我的closePopUpView是:

func closePopUpView(sender: UIButton!){
    println("pressed!!")
}

我搜索了互联网但我找不到解决方案。

0 个答案:

没有答案