Objective c Xcode是否删除触摸事件图像?

Objective c Xcode是否删除触摸事件图像?,objective-c,cocoa-touch,uiview,uiimageview,uitouch,Objective C,Cocoa Touch,Uiview,Uiimageview,Uitouch,我用这段代码在屏幕上显示随机图像 - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; UIImageView *cloud = [[UIImageView alloc]

我用这段代码在屏幕上显示随机图像

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    UIImageView *cloud = [[UIImageView alloc] 
                               initWithImage:[UIImage imageNamed:@"spit.png"]];

    cloud.center = CGPointMake(random() % 250, random() % 400); //Random place
    [cloud setAlpha:1];
    [self.view addSubview:cloud];
    [cloud release];

    cloud.frame = CGRectMake(0, 0, 300, 300); 

    [UIView beginAnimations: @"cloddy" context: nil];
    [UIView setAnimationDuration: 0.5f];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseIn];

    // Size when done
    cloud.frame = CGRectMake(0, 0, 75, 75); 
    cloud.center = location;
    [UIView commitAnimations]; 
}

触摸几下屏幕就会有点满了。如何在另一个iAction中删除它们?为什么即使我使用的是random,动画也总是从左上角开始?

假设添加到视图中的子视图只有

- (IBAction)clearClouds:(id)sender{
    [[[self view] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
}
云始终从左上角开始,因为这一行:
cloud.frame=CGRectMake(0,0,300,300)将其原点重置为0,0。Move
cloud.center=CGPointMake(random()%250,random()%400)位于设置云框架的行下方,您应该已全部设置完毕