Something wrong with JSPatch



我不知道我的代码出了什么问题。当我单击按钮时,方法无法执行。这是我的代码:

configView: function() {
    var button = UIButton.buttonWithType(0);
    button.setFrame({x:10,y:10,width:100,height:100});
    button.setTitle_forState('touch me',0);
    self.view().addSubView(button);
    button.setBackgroundColor(UIColor.redColor());
    button.setCenter(self.view().center());
    button.addTarget_action_forControlEvents(self,'touch',0);
},
touch:function(){
    console.log('touchme');
}

这可能是问题所在吗? button.addTarget_action_forControlEvents(self,'touch',0)

将 Touchupinside 作为事件,以便它正常工作。

[Button addTarget:self action:@selector(touch) forControlEvents:UIControlEventTouchUpInside];

我自己得到的,UIControlEventTouchDown类型是NS_OPTIONS类型UIControlEventTouchDown = 1 << 0,,所以类型的intValue是1,我修改了我的代码button.addTarget_action_forControlEvents(self,'touch',1),它会起作用。

最新更新