我想在主視圖上的每個水龍頭上動態創建UIImageView
,並且還想通過手指移動來移動所有創建的UIImageView
。我已成功在每次觸摸我的代碼時動態創建低於:如何在iPhone中管理多個UIImageView
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint pt = [touch locationInView:self.view];
imgView = [[[UIImageView alloc] initWithFrame:CGRectMake(pt.x,pt.y, 100, 100)] autorelease];
imgFilepath = [[NSBundle mainBundle] pathForResource:@"img" ofType:@"png"];
img = [[UIImage alloc] initWithContentsOfFile:imgFilepath];
imgView.tag=i;
[imgView setImage:img];
[img release];
[self.view addSubview:imgView];
}
現在我想通過手指移動它來移動任何動態創建的UIImageView
的。 謝謝。