0
我嘗試在多個imageView之間進行區別,您可以使用IBAction創建這些圖像查看器。iOs 5 SDK UIGestureRecognizer:多個圖像查看器之間的差異
這裏是我的動作代碼:
-(IBAction) addObject:(id)sender {
UIImage * image = [UIImage imageNamed:@"Stuhl.png"];
CGRect rect = CGRectMake(0.0f, 40.0f, image.size.width, image.size.height);
Bild *newImageView = [[Bild alloc] initWithFrame:rect];
[newImageView setImage:image];
newImageView.userInteractionEnabled = TRUE;
[theView addSubview:newImageView];
[arryData addObject:newImageView];
}
然後我的問題:我如何才能在ImageView的有所不同,當我點擊與IBAction爲ADDOBJECT多次按鈕?
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer.view != imageView /*<---Here's my problem*/)
return NO;
if (gestureRecognizer.view != otherGestureRecognizer.view)
return NO;
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] || [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
return NO;
}
希望尋求幫助, 文森特
謝謝,但那不是我的問題,我用於gesturerecognizer的代碼是從蘋果示例代碼複製的。我的問題是,當我多次點擊添加按鈕時,有多個圖像被命名爲「imageView」。在gestureRecognizers方法中,我必須告訴它,imageView是如何調用的,我想要移動,但是如果有更多的,我不知道如何讓程序給它們分別命名的圖像視圖。 –
你可以設置標籤,例如,UIImageView * imageView = [[UIImageView alloc] init];那麼imageView.tag = 100;之後,在gestureRecognizer上,檢查其視圖的標記,gestureRecognizer.view.tag,可以比較標記。 –