- Fix not show picker when close native image picker controller

This commit is contained in:
Giuseppe Nucifora 2016-04-21 13:41:40 +02:00
parent 60b14b37a7
commit efc65445a7
2 changed files with 89 additions and 89 deletions

View File

@ -50,8 +50,6 @@
if (!self.didUpdateConstraints) {
self.didUpdateConstraints = YES;
[self.contentView autoPinEdgesToSuperviewEdges];
[_photoImageView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:8];
@ -64,6 +62,8 @@
[_loadingSpinner autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
[_loadingSpinner autoAlignAxisToSuperviewAxis:ALAxisVertical];
self.didUpdateConstraints = YES;
}
}

View File

@ -384,7 +384,9 @@
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
[self presentViewController:picker animated:YES completion:nil];
[_targetController presentViewController:picker animated:YES completion:^{
[self dismissAnimated:YES];
}];
}
}
@ -394,7 +396,9 @@
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
[self presentViewController:picker animated:YES completion:nil];
[_targetController presentViewController:picker animated:YES completion:^{
[self dismissAnimated:YES];
}];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
@ -409,7 +413,9 @@
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:nil];
[picker dismissViewControllerAnimated:YES completion:^{
[self showImagePickerInController:_targetController];
}];
}
#pragma mark - Show
@ -420,6 +426,8 @@
- (void)showImagePickerInController:(UIViewController *)controller animated:(BOOL)animated {
if (_isVisible != YES) {
_targetController = controller;
if ([delegate respondsToSelector:@selector(imagePickerWillOpen)]) {
[delegate imagePickerWillOpen];
}
@ -428,7 +436,7 @@
[self setTransitioningDelegate:transitionController];
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[controller presentViewController:self animated:NO completion:^{
[_targetController presentViewController:self animated:NO completion:^{
[_imagePickerView setNeedsUpdateConstraints];
[_imagePickerView updateConstraintsIfNeeded];
@ -479,7 +487,6 @@
[_imagePickerView setNeedsUpdateConstraints];
[_imagePickerView updateConstraintsIfNeeded];
_isVisible = NO;
if (animated) {
[UIView animateWithDuration:_animationTime
@ -520,13 +527,6 @@
}
}
- (void) dismissViewControllerAnimated:(BOOL)animated completion:(void (^ _Nullable)(void))completion {
[self dismissAnimated:animated];
if (completion) {
completion();
}
}
@end