0

我正在使用UIImagePickerController通过不关闭模式来进行多项选择,并添加一个子视图来计算所选图像的数量。

这是非常基本的,我向选择器展示的是:

- (IBAction)choseImagesTouched:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [imagePicker setDelegate:self];

    //place image picker on the screen
    [self presentViewController:imagePicker animated:YES completion:nil];
}

我需要做的一件事是为任何选定的图像添加复选标记,就像他们在添加到相册时在照片应用程序中所做的那样。

我能否以某种方式监听触摸事件、获取坐标并在屏幕上的该位置添加子视图或覆盖视图,以指示图像已被选中?

4

1 回答 1

0
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
        CGPoint location = [touch locationInView: self.view];
        //... check if there is an image at this location and do something...
    }
}

您还可以使用touchesMoved:touchesEnded:

于 2012-07-23T21:40:02.243 回答