我会很快。我有 6 张图片,附有 6 个手势和一个 IBAction。我希望每个手势都将参数传递给动作,所以我不必编写 6 个单独的动作。这是我的代码:
oneImage =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"one.gif"]];
two Image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"two.gif"]];
+4 more images
UITapGestureRecognizer *oneGest=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(insertChar:)];
UITapGestureRecognizer *twoGest=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(insertChar:)];
+4 more gestures
-(IBAction)insertChar:(id)sender
{
textfield.text = [textfield.text stringByAppendingString:@" PASS HERE VALUE FROM GESTURE,"ONE","TWO",etc "];
}