一旦图像被点击,我正在尝试添加一个动作。我首先尝试添加一个 C4Button,然后给它一个图像,但这根本没有成功。所以现在我试图在图像中添加一个点击功能这里是代码
-(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?)。它们适用于形状,我认为它应该适用于图像,但显然它没有......