2012-07-23 45 views
0

我使用UIImagePickerController通过不关闭模式并添加子视图来计算所选图像的数量来执行多选。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]; 
} 

有一件事我需要的,是一个复选标记添加到任何选择的图像,就像他们在照片应用程序添加时做到一张专辑。

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

+0

你是怎么解决这个@MartinHN,不幸的是我试图实现同样的方式,现在不知道如何展现对号覆盖。 – 2015-09-01 17:13:03

+0

不幸的是我不记得了。我不记得它是否已经在更新的API中可用,据我所知,iOS 9应该有一些东西。 – MartinHN 2015-09-01 20:45:31

+0

@ShabarinathPabba你应该能够使用这个DKImagePickerController库:https://github.com/zhangao0086/DKImagePickerController – MartinHN 2015-09-02 06:38:06

回答

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:

+0

我对这种方法有了第二个想法......当用户滚动时会发生混乱,不是。我必须跟踪选定的照片,所以我认为我需要使用Assets Library来获取多张照片。 – MartinHN 2012-07-23 21:44:00