1
我有一个视图控制器,其中显示图像的网格/数组,其中每个图像视图都是自定义笔尖(自定义笔尖,因为图像的名称为&喜欢/不喜欢的图标)。所以我在我的视图控制器viewDidLoad
中显示了像这样的图像网格。iOS手势处理:在使用自定义UIView时添加手势识别器的位置
int row=0, col=0;
for (int i=0; i<arrayImg.count; i++) {
NSArray *topObj = [[NSBundle mainBundle] loadNibNamed:@"CustomImageView" owner:nil options:nil];
CustomImageView *imgView = [topObj objectAtIndex:0];
imgView.frame = CGRectMake(180*col+10, 180*row+10, 170, 170);
// custom image values inserted here
[self.view addSubView:imgView];
// update the row,col variables here
}
现在我需要为屏幕上显示的每个图像添加一个水龙头手势识别器。在这种情况下,在自定义笔尖/类中添加手势识别器CustomImageView
似乎符合逻辑。 CustomImageView
延伸UIView
,所以它似乎无法在此处声明手势识别器(自动完成不会出现,语法高亮也不起作用)。我在这里错过了什么?
+1谢谢塞尔吉奥。这工作。感谢有关自动完成的提示会牢记在心。 :) – vikmalhotra