UIPickerController memory leak after selecting photo - ios

I am having a memory leak whenever I select a photo within my image picker controller. I have tried doing my own research as to why this happens but I have found nothing close to my situation. Various tutorials I have learnt from have a memory leak when using the image picker controller as well. All I am doing is choosing a photo and then the image picker controller dismisses. I have tried finding a solution for many days now, but no luck, I tend to try to find solutions before asking for help, any help is greatly appreciated, here is my code.
#property (nonatomic, strong) UIImagePickerController *imagePicker;
#property (nonatomic, strong) UIImage *image;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
if (self.image == nil && [self.videoFilePath length] == 0) {
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
self.imagePicker.videoMaximumDuration = 10;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.imagePicker.sourceType];
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImage *newImage = [self resizeImage:self.image toWidth:200 andHeight:200];
self.image = newImage;
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
// A video was taken/selected!
NSURL *videoUrl = info[UIImagePickerControllerMediaURL];
self.movieUrl = videoUrl;
self.videoFilePath = videoUrl.absoluteString;
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the video!
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)) {
UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil);
}
}
}
[self dismissViewControllerAnimated:YES completion:nil];
}
When I use instruments I get, that the responsible instance is in Core Foundation. CFString. I am not very familiar with debugging memory leak's like these in Objective-C. I'd appreciate a hand here! Thank You.

The leak is coming from Apple's code. The only thing you are doing wrong is retaining the UIImagePickerController as an instance property. Stop doing that; create the UIImagePickerController as a temporary local variable each time you present it. Apart from that, there's nothing you can do.

Related

IOS image picker in navigation view controller

I am trying to browse an image and display in imageview using UIImagePickerController. Basically the view I am using to browse the image is based on navigationController.
But using the below code after I select the image and come back to view, I can see that the view is flickering to left right and the image is not showing in image view.
Actually the entire source code is quit long, thats why I post the image picker part only. If required I can post more code.
RegistrationFormViewController.h
#interface RegistrationFormViewController : ViewController
<UIImagePickerControllerDelegate,UINavigationControllerDelegate,CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
UIImagePickerController *imagePickerController;
}
#property (strong, nonatomic) CLLocationManager *locationManager;
#property (weak, nonatomic) IBOutlet UIImageView *imageUser;
- (IBAction)registerBt:(id)sender;
RegistrationFormViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
_barButtonBack.target = self.revealViewController;
_barButtonBack.action = #selector(revealToggle:);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(tapDetected)];
singleTap.numberOfTapsRequired = 1;
[self.imageUser setUserInteractionEnabled:YES];
[self.imageUser addGestureRecognizer:singleTap];
}
-(void)tapDetected{
NSLog(#"single Tap on imageview");
imagePickerController = [[UIImagePickerController alloc]init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
#pragma mark - ImagePickerController Delegate
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
// Dismiss the image selection, hide the picker and
//show the image view with the picked image
[picker dismissViewControllerAnimated:YES completion:nil];
[self.imageUser setImage:image];
self.imageUser.contentMode = UIViewContentModeScaleAspectFill;
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
There is no issue in your code that you showed here. However try this in didFinishPickingImage -
dispatch_async(dispatch_get_main_queue(), ^{
self.imageUser.contentMode = UIViewContentModeScaleAspectFill;
[self.imageUser setImage:image];
});
and move this code to viewDidLoad
imagePickerController = [[UIImagePickerController alloc]init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
you can also check whether you are getting the image or not using breakpoint.
try this delegate method
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:NULL];
}
In viewcontroller.m file, just put this code:
#import <AssetsLibrary/AssetsLibrary.h>
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
- (IBAction)Gallery:(id)sender {
self.ImagePickerController = [[UIImagePickerController alloc]init];
self.ImagePickerController.delegate = self;
self.ImagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentViewController:self.ImagePickerController animated:YES completion:nil];
}
- (IBAction)Camera:(id)sender {
self.ImagePickerController = [[UIImagePickerController alloc]init];
self.ImagePickerController.delegate = self;
self.ImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:self.ImagePickerController animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
[picker dismissViewControllerAnimated:YES completion:nil];
NSURL *imageUrl = (NSURL *)[info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *representation = [myasset defaultRepresentation];
CGImageRef resolutionRef = [representation fullResolutionImage];
if (resolutionRef) {
UIImage *image = [UIImage imageWithCGImage:resolutionRef scale:1.0f orientation:(UIImageOrientation)representation.orientation];
self.SelectedImage.image =image;
}
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(#"cant get image - %#",[myerror localizedDescription]);
};
if(imageUrl)
{
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc]init];
[assetslibrary assetForURL:imageUrl resultBlock:resultblock failureBlock:failureblock];
}
}
In viewcontroller.h file
#interface ViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
#property (nonatomic)UIImagePickerController *ImagePickerController;
#property (weak, nonatomic) IBOutlet UIImageView *SelectedImage;

Xcode: Add attachment using picker to email

I have developed an app that allows the user to choose a video from the photo gallery and send it as an attachment in an email. I am able to choose a video from the gallery and proceed with sending the email but the video does not get attached with the email. There are no errors in the console.
ViewController.h:
#import <UIKit/UIKit.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <MessageUI/MessageUI.h>
#interface ViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate,MFMailComposeViewControllerDelegate>
#property (strong, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)choose:(id)sender;
#end
ViewController.m:
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIAlertController *myAlertController = [UIAlertController alertControllerWithTitle:#"MyTitle"
message: #"MyMessage"
preferredStyle:UIAlertControllerStyleAlert ];
[self presentViewController:myAlertController animated:YES completion:nil];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)choose:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
[self performSelector:#selector(email:) withObject:chosenImage afterDelay:0.5];
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)email:(UIImage *)choosenImage{
NSString *iOSVersion = [[UIDevice currentDevice] systemVersion];
NSString *model = [[UIDevice currentDevice] model];
NSString *version = #"1.0";
NSString *build = #"100";
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setToRecipients:[NSArray arrayWithObjects: #"support#myappworks.com",nil]];
[mailComposer setSubject:[NSString stringWithFormat: #"MailMe V%# (build %#) Support",version,build]];
NSString *supportText = [NSString stringWithFormat:#"Device: %#\niOS Version:%#\n\n",model,iOSVersion];
supportText = [supportText stringByAppendingString: #"Please describe your problem or question."];
[mailComposer setMessageBody:supportText isHTML:NO];
NSData *data = UIImagePNGRepresentation(choosenImage);
[mailComposer addAttachmentData:data mimeType:#"image/png" fileName:#""];
[self presentViewController:mailComposer animated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
#end
Any suggestion/help would be much appreciated. Thank you.
You mentioned that you're trying to attach a video, and you've configured your UIImagePickerController to limit the mediaTypes to only videos. The problem then is that you're asking for the "edited image" in the "didFinishPickingMediaWithInfo" method:
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
The user did not pick an image - they picked a video. You need to use this instead:
NSURL *chosenVideoUrl = info[UIImagePickerControllerMediaURL];
NSData *videoData = [NSData dataWithContentsOfURL:chosenVideoUrl];
You can then pass the videoData to your email method and attach to the email. Be sure to update the mimeType from "image/png" to "video/mp4", as well.
If u need to attach both video and image you have write to code for both,but you written only for attaching an image.You can try the code below for getting both
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if ([[info objectForKey:UIImagePickerControllerMediaType] isEqual:(NSString *)kUTTypeMovie]) {
NSString *videoURL = info[UIImagePickerControllerMediaURL];
[self emailImage:nil orVideo:videoURL];
}else {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
[self emailImage:chosenImage orVideo:nil];
}
[picker dismissViewControllerAnimated:YES completion:NULL];
}
UIImagePickerControllerMediaURL will return file url unlike UIImagePickerControllerEditedImage ,so can use NSData method dataWithContentsOfFile as bellow.
if (choosenImage) {
NSData *data = UIImagePNGRepresentation(choosenImage);
NSString *filename = [NSString stringWithFormat:#"Image_%#.png",TimeStamp];
[mailComposer addAttachmentData:data mimeType:#"image/png" fileName:filename];
[self presentViewController:mailComposer animated:YES completion:nil];
}else {
NSData *data = [NSData dataWithContentsOfFile:videoFile];
NSString *filename = [NSString stringWithFormat:#"Video_%#.mp4",TimeStamp];
[mailComposer addAttachmentData:data mimeType:#"video/mp4" fileName:filename];
[self presentViewController:mailComposer animated:YES completion:nil];
}
it will be good if you give a filename for the attachment it will be help full after it downloading.if you wish you can use a TimeStamp for that.
#define TimeStamp [NSString stringWithFormat:#"%f",[[NSDate date] timeIntervalSince1970] * 1000]

send me to detail view after taking picture with UIImagePickerController

I'm stuck on the following issue: When I'm taking a picture with UIImagePickerController i want to send the user to another view where the selected image is visible and he/she can fill some more information. But the detailview doesn't show up, instead of that when I take the picture the app hangs, even though the picture is saved on my phone. What can I do?
My code:
#interface PhotoViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
#property (nonatomic, strong) UIImagePickerController *imagePicker;
#property (nonatomic, strong) UIImage *image;
#end
#import "PhotoViewController.h"
#import "PostViewController.h"
#import <MobileCoreServices/UTCoreTypes.h>
#implementation PhotoViewController
- (void)viewDidLoad {
// Do any additional setup after loading the view.
[super viewDidLoad];
}
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (self.image == nil) {
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
self.imagePicker.videoMaximumDuration = 10;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.imagePicker.sourceType];
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:NO completion:nil];
[self.tabBarController setSelectedIndex:0];
}
-(void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// A photo was taken/selected!
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the image!
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
}
I've also posted my Storyboard to make things clear.
Your screenshot is too small to be legible. Post a link to a file on another site.
In any case, it looks to me like the problem is that you're not dismissing the image picker.
-(void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
//--------------------------------------------------
//This is the line you're missing
picker.dismissViewControllerAnimated(true, completion: nil)
//--------------------------------------------------
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// A photo was taken/selected!
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the image!
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
}

Share a picture in chat, base64 issue

I am developing a chat, in chat I need to share pictures, my app has a button to select an image from gallery.
This is my button code:
[upBtn2 addTarget:self action:#selector(uploadImage:) forControlEvents:UIControlEventTouchUpInside];
In gallery the user can select an image to share in chat with someone else, the conversation is just 1 to 1 chat.
This is my code.
- (IBAction)uploadImage:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
newMedia = NO;
}
}
-(void)imagePickerControllerDidCancel:
(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info
objectForKey:UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:YES completion:nil];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
Uploadedimage.image=image;
if (newMedia)
UIImageWriteToSavedPhotosAlbum(image,
self,
#selector(image:finishedSavingWithError:contextInfo:),
nil);
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
// Code here to support video if enabled
}
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
// [self performSelector:#selector(uploadToServer) withObject:nil afterDelay:0.0];
XMPPMessage *message = [[XMPPMessage alloc] initWithType:XMPP_MESSAGE_TYPE_CHAT to:[self.contact jid]];
NSData *imageData = UIImagePNGRepresentation(image);
NSString *imageStr = [GTMBase64 stringByEncodingData:imageData];
//decoding
NSData *imageData2 = [GTMBase64 decodeString:imageStr];
[message addBody:imageStr];
[[[AppDelegate appDelegate] xmppStream] sendElement:message];
XMPPJID *myJID = [[[AppDelegate appDelegate] xmppStream] myJID];
[self addMessage:#{
XMPP_TIMESTAMP: [NSDate date],
XMPP_MESSAGE_USERNAME: [myJID bare],
XMPP_MESSAGE_TEXT: imageStr,
}];
[self.tableView reloadData];
[self scrollToBottom:true];
}
- (void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
if (error) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: #"Archivo guardado"
message: #"Error al guardar archivo"\
delegate: nil
cancelButtonTitle:#"Aceptar"
otherButtonTitles:nil];
[alert show];
}
}
I am getting an issue, the code it is showing
2014-10-14 11:01:21.973 Ucity[2907:60b] messages: (
{
text = "/9j/4AAQSkZJRgABAQAAAQABAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAE9KADAAQAAAABAAAFcAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/..."
I need to see the image there but for some reason its showing that text.
I am using GTMBase 64 library
#import "GTMBase64.h"
Can someone help me to fix this problem?
That cryptic text is the image. It's just the base-64 string representation of the image. I assume you're doing this base-64 encoding for a reason (e.g. this format is required by some service to which you are uploading the image).
I'm presuming from your question that you want to show the image somewhere. I'm just trying to reconcile this with this code, in which you retrieved the image, converted it to a base-64 string, then discarded the original image, and now you're asking us why you're only seeing the string.
If you need the image again, there are a couple of options:
Keep the UIImage (or the NSData) that you grabbed in didFinishPickingMediaWithInfo.
You could alternatively convert the base-64 string back to a NSData (and then create a UIImage from that). This is a pretty convoluted approach, but it would work.
As an aside, if you wanted, you could probably replace GTMBase64.h with the native base-64 methods that Apple exposed in iOS 7. See https://stackoverflow.com/a/19794564/1271826.
Also, I don't personally like grabbing the UIImage and doing the PNG conversion to get the NSData. I always grab the original asset as shown here. This ensures there's no loss of information and that the resulting NSData isn't larger than it needs to be.

How to take video from gallery like image inside application in ios

In my application i need to take video from simulator and i need to upload to server.can any one help to me.Please provide any solution as soon as possible.
Thanks & Regards
T.swathi
First, create a UIImagePickerController
On your class, you will need to implement the UIImagePickerControllerDelegate protocol and wire it up to the delegate property on the picker. You should be able to get the location of the media selected from didFinishPickingMediaWithInfo once the user has selected something.
//Check in iOS Device not in Simulator
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// this is the file system url of the media
NSURL* videoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
// TODO: read in data at videoUrl and write upload it to your server
}
Use this function may be help full
-(void)selectVideoButtonClicked:(id)sender{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentViewController:imagePicker animated:YES completion:nil];
}
and take delege of "UIImagePickerControllerDelegate" & and import framework and using delegate function pick video from library
MobileCoreServices.framework first import in project and after than import in file CoreServices/CoreServices.h
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
// Handle a movie capture
if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo) {
NSString *moviePath = [[info objectForKey: UIImagePickerControllerMediaURL] path];
NSLog(#" Video Path %#",moviePath);
NSString *fileName = [[NSString alloc]init];
//If you wants get File Name Then you can use this
if ([moviePath rangeOfString:#"//"].location != NSNotFound) {
NSString *separatorString = #"//";
NSArray *disSplit = [moviePath componentsSeparatedByString:separatorString];
fileName = disSplit[1] ;
// [self videoUploadingDirect:moviePath];
}
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
}
}
[self dismissViewControllerAnimated:YES completion:nil];
}
Thanks :)

Resources