我试图添加一个动作,一旦图像被点击。我第一次尝试添加一个C4Button,然后给它一个图像,但那根本不起作用。所以,现在我想只需添加一个水龙头函数的图像 这里是代码图像作为按钮C4
-(void)setup{
//IMAGE AS BUTTON
C4Image *photoButtonImage=[C4Image imageNamed:@"icons-02.png"];
photoButtonImage.height=NavBarHeight;
photoButtonImage.center=CGPointMake(self.canvas.width/2, self.canvas.height-NavBarHeight/2);
[self.canvas addImage:photoButtonImage];
[photoButtonImage addGesture:TAP name:@"tap" action:@"tapped"];
}
-(void)tapped {
C4Log(@"tapped!");
}
应用[photoButtonImage addGesture:TAP name:@"tap" action:@"tapped"];
方法self
完全工作正常,但没有任何反应,如果我把它添加到图像(PhotoButtonImage
)。 我查看了2个答案(Gesture controls crash when calling methods on C4WorkSpace.m和How do I apply a UILongPressGestureRecognizer to a shape in C4?)。他们是为形状,我认为它应该只是对图像工作相同,但显然它不...
谢谢!这工作得很好! – suMi