Reputation: 4695
I am developing an app which allows you to select photos and place them into different positions. The workflow is basically:
UIImagePickerController
displaysI would like it so that if the user goes through this workflow for a second time, the UIImagePickerController
when displayed will be showing the same album, and position within that album, that the user was last at.
I've tried saving a reference to the UIImagePickerController
, as well as the UIPopoverController
, so that they are created only once. However, every time I present the popover containing the UIImagePickerController
, it is back at the main photos menu (eg. Camera Roll, Photo Library, My Photo Stream).
Any ideas for how to achieve what I'm after?
Upvotes: 2
Views: 980
Reputation: 23278
Just to point you to right direction. You can use asset library to show the images as a picker. You can use the apple sample code MyImagePicker. The method [[assetsLibrary] enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup *group, BOOL *stop)
can be used for photo album. Using the asset library you can check which image was selected last and then use the method,
- (void)enumerateAssetsAtIndexes:(NSIndexSet *)indexSet options:(NSEnumerationOptions)options usingBlock:(ALAssetsGroupEnumerationResultsBlock)enumerationBlock;
You can use this method next time to enumerate which image onwards you want to enumerate. This method can accept an indexSet as [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(index, count)]
which should help to indicate the last selected image.
To know more about how to use asset library check this.
Upvotes: 0
Reputation: 24248
keep a UIImagePickerController
obj in .h class (for example imagePicker
)
alloc the obj once (for example in viewDidLoad
)
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self.view addSubview:imagePicker.view];
imagePicker.view.hidden = YES;
imagePicker.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
imagePicker.view.bounds = CGRectMake(0,20,self.view.frame.size.width, self.view.frame.size.height);
In didFinishPickingMediaWithInfo
if([[info valueForKey:UIImagePickerControllerMediaType] isEqualToString:@"public.image"]){
imagePicker.view.hidden = YES;
}
When you want to show the imagePickerView
just do
imagePicker.view.hidden = NO;
Upvotes: 1
Reputation: 179
Use AlAssetsLibrary. It control the image & video capture under the application. there a demo on apple.
look for this or
if you want to make a cutomize album for the image and video here a great example.
https://github.com/Kjuly/ALAssetsLibrary-CustomPhotoAlbum
Upvotes: 0
Reputation: 9091
You can use ALAssetsLibrary . But this will cost you more effort. First time use – enumerateGroupsWithTypes:usingBlock:failureBlock:
to list all album and remember user's choice. And at second time. Just use that album:ALAssetsGroup
's – enumerateAssetsUsingBlock:
to list all the images and videos. Apple has a few demo you can have a look PhotosByLocation MyImagePicker
Upvotes: 1
Reputation: 473
It should be possible to reach into the resulting UITableView
and then find its content offset. You can do this by searching the subviews of the UIImagePickerController
's view
property for a table view.
for (UIView *view in controller.view) {
if ([view isKindOfClass:[UITableView class]]) {
contentOffset = [(UITableView *)view contentOffset];
}
}
When you represent the view controller, you will want to restore the content offset in a similar fashion.
Note, I haven't actually tested to see the view hierarchy of the UIImagePickerController
. Verify its structure by printing its subviews. There is also no guarantee that the structure will stay the same, since you are diving into the private implementation (though it's important to note you are not actually using any private APIs so this is okay).
Upvotes: 0