笏我试图是,每次用户触摸屏幕,我是在屏幕添加图像在运行时阵列和清除它按钮点击
UIImage *img = [UIImage imageNamed:@"shoot_a.png"]; //bullet shot image
im.image = img;
[self.view addSubview:im];
增加一个小bulletr图像时,如果用户触摸的50倍,屏幕上会显示50张图片。
现在我想,如果用户点击一个按钮,所有这些子弹应该从屏幕上删除。
我希望我明确我的问题。
[im removefromsuperview]
不适合我。
如果我想在运行时将图像添加到数组,我该如何添加和释放? 还是有没有更好的方法来清除所有图像 问候。
这是我的联系方式,即时通讯将在屏幕上FRM heere子弹图片,,但这些图像没有在阵
// Touch method
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if(restrictTap == YES){
NSUInteger numTaps = [[touches anyObject] tapCount];
NSString *numTapsMessage = [[NSString alloc] initWithFormat:@"%i", numTaps];
[numTapsMessage release];
// getting location
CGPoint touchLocation = [[touches anyObject] locationInView:self.view];
NSString *locationMessage = [[NSString alloc] initWithFormat:@"Location: X = %.0f Y = %.0f", touchLocation.x, touchLocation.y];
//bullet shot image
im = [[UIImageView alloc] initWithFrame:CGRectMake(self.location.x, self.location.y, 12.0, 12.0)];
float j =self.location.x;
float i =self.location.y;
img = [UIImage imageNamed:@"shoot_a.png"]; //bullet shot image
im.image = img;
//im.hidden = NO;
[self.view addSubview:im]; ///bullet shot image is over transparent view
[imageArray addObject:img];
}
}
@ this [imageArray addObject:im]; 我每次都得到0个对象.. wat做什么? – iscavengers 2010-07-08 05:19:27
@shi:你是什么意思?数组保持空白?现在有两件事:你有'addObject:img'而不是'addObject:im',并且图像视图被过度保留。 – 2010-07-08 06:52:22
@georg yes array is emmmmpty,没有图像被添加到数组中。 它显示0个对象 好吧,让我试试img im的instread。 – iscavengers 2010-07-08 06:58:20