You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

71 lines
2.4 KiB

//
// XHPhotographyHelper.m
// MessageDisplayExample
//
// Created by HUAJIE-1 on 14-5-3.
// Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
//
#import "XHPhotographyHelper.h"
#import "XHMacro.h"
@interface XHPhotographyHelper () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, copy) DidFinishTakeMediaCompledBlock didFinishTakeMediaCompled;
@end
@implementation XHPhotographyHelper
- (instancetype)init {
self = [super init];
if (self) {
}
return self;
}
- (void)dealloc {
self.didFinishTakeMediaCompled = nil;
}
- (void)showOnPickerViewControllerSourceType:(UIImagePickerControllerSourceType)sourceType onViewController:(UIViewController *)viewController compled:(DidFinishTakeMediaCompledBlock)compled {
if (![UIImagePickerController isSourceTypeAvailable:sourceType]) {
compled(nil, nil);
return;
}
self.didFinishTakeMediaCompled = [compled copy];
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera) {
// imagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];//去掉视频
}
[viewController presentViewController:imagePickerController animated:YES completion:NULL];
}
- (void)dismissPickerViewController:(UIImagePickerController *)picker {
WEAKSELF
[picker dismissViewControllerAnimated:YES completion:^{
weakSelf.didFinishTakeMediaCompled = nil;
}];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
if (self.didFinishTakeMediaCompled) {
self.didFinishTakeMediaCompled(image, editingInfo);
}
[self dismissPickerViewController:picker];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if (self.didFinishTakeMediaCompled) {
self.didFinishTakeMediaCompled(nil, info);
}
[self dismissPickerViewController:picker];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissPickerViewController:picker];
}
@end