首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >didFinishPickingMediaWithInfo中的应用程序崩溃

didFinishPickingMediaWithInfo中的应用程序崩溃
EN

Stack Overflow用户
提问于 2013-01-28 17:45:29
回答 2查看 2.1K关注 0票数 0

当用户录制视频然后单击choose时,我的应用程序崩溃。下面是我的代码:

代码语言:javascript
复制
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        picker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
        //picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
        picker.allowsEditing = NO;
        picker.delegate = self;
        picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
        [self presentModalViewController:picker animated:YES];




-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   // [self dismissModalViewControllerAnimated:YES];
    AppDelegate *del = [[UIApplication sharedApplication]delegate];

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];


    moviePath = [[info objectForKey:UIImagePickerControllerMediaURL]path];..//using this for upload

    del.globalMoviePath = moviePath;

    if (CFStringCompare ((__bridge CFStringRef) mediaType, kUTTypeMovie, 0)== kCFCompareEqualTo)
    {

        moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

        del.globalMoviePath = moviePath;


        picker.videoMaximumDuration = 60.0f;
        picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;


        NSLog(@"nrgkrg===>%@",moviePath);

       videoUrl=(NSURL*)[info objectForKey:UIImagePickerControllerMediaURL];
         NSLog(@"Urlllll===>%@",videoUrl);

        videoData = [NSData dataWithContentsOfURL:videoUrl];

        del.globalMoviePath = moviePath;

        NSLog(@"video is====>%@",del.globalMoviePath);

        MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
        UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
        [player stop];

        videoImage = [[UIImageView alloc]initWithImage:thumbnail];

        //NSLog(@"imegsvideo====>%@",thumbnail);


        //if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath))
        //{
          //  UISaveVideoAtPathToSavedPhotosAlbum (moviePath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
       // }
        //MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
        //UIImage  *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
    }

    [self dismissModalViewControllerAnimated:YES];



      //[[picker parentViewController] dismissModalViewControllerAnimated: YES];


}

当用户录制视频并单击选择应用程序时,应用程序会崩溃,但当从摄像头中选择时,应用程序运行良好。

请帮帮我!!

日志如下:

代码语言:javascript
复制
Nov 29 20:28:14  ReportCrash[259] <Notice>: Formulating crash report for process [254]
Nov 29 20:28:14  com.apple.launchd[1] <Warning>: (UIKitApplication:[0xcc37]) Job appears to have crashed: Segmentation fault: 11
Nov 29 20:28:14  backboardd[52] <Warning>: Application 'UIKitApplication:[0xcc37]' exited abnormally with signal 11: Segmentation fault: 11
Nov 29 20:28:14  ReportCrash[259] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Nov 29 20:28:14  ReportCrash[259] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/ using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) mstreamd: Checking on job state for Photo Stream
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) mstreamd: No jobs scheduled for Photo Stream.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) mstreamd: Checking on job state for Shared Stream
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) mstreamd: No jobs scheduled for Shared Stream.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) PS: Media stream daemon stopping.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x1ee72590>: Shared Streams daemon shutting down.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x1ee72590>: Shutting down state machine for personID 1446684163.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSASStateMachine: 0x1ed3e060>: Shutting down uploader.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSASStateMachine: 0x1ed3e060>: Shutting down downloader.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSASStateMachine: 0x1ed3e060>: Shutting down state machine.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x1ee72590>: Shutting down model.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSASServerSideModel: 0x1ed39d50>: Command Queue has shut down.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x1ee72590>: Model has shut down.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x1ee72590>: Shared Streams daemon has shut down.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1ed394b0>: Stopping post-foreground timer.
Nov 29 20:28:38  mstreamd[257] <Notice>: (Warn ) mstreamd: mstreamd shutting down.
Nov 29 20:49:16  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_screen_off even though we are not in it, doing nothing
Nov 29 20:49:16  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableDetect 0
Nov 29 20:49:16  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableType Detached
Nov 29 20:49:16  kernel[0] <Debug>: virtual IOReturn AppleUSBDeviceMux::message(UInt32, IOService *, void *) - kMessageInterfaceWasDeActivated
Nov 29 20:49:16  kernel[0] <Debug>: AppleUSBDeviceMux::reportStats: USB mux statistics:
Nov 29 20:49:16  kernel[0] <Debug>: USB mux: 190 reads / 0 errors, 899 writes / 0 errors
Nov 29 20:49:16  kernel[0] <Debug>: USB mux: 0 short packets, 0 dups
Nov 29 20:49:16  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_charging even though we are not in it, doing nothing
Nov 29 20:49:16  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_screen_off even though we are not in it, doing nothing
Nov 29 20:49:16  ptpd[104] <Notice>: PTP interface has been deactivated.
Nov 29 20:49:18  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_asleep even though we are not in it, doing nothing
Nov 29 20:49:18  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableDetect 1
Nov 29 20:49:18  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableType USBHost
Nov 29 20:49:18  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_screen_off even though we are not in it, doing nothing
Nov 29 20:49:18  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_screen_off even though we are not in it, doing nothing
Nov 29 20:49:19  ptpd[104] <Notice>: PTP interface has been activated at high speed.
Nov 29 20:49:56  lockdownd[29] <Notice>: 2fe93000 special_case_get: MGCopyAnswer(kMGQMobileEquipmentIdentifier) returned NULL
Nov 29 20:49:56  lockdownd[29] <Notice>: 2fe93000 copy_phonenumber: CTSettingCopyMyPhoneNumber() returned NULL
Nov 29 20:49:56  mobile_installation_proxy[265] <Error>: 0x3cbd7b88 MobileInstallationSlowLookupBreak: MobileInstallationBrowse was called without specifying an options dictionary containing kLookupReturnAttributesKey. This usage is inefficient and may cause performance problems. Break on MobileInstallationSlowLookupBreak to debug.
Nov 29 20:49:56  mobile_installation_proxy[265] <Error>: 0x3cbd7b88 MobileInstallationSlowLookupBreak: Existing options dictionary: <CFBasicHash 0x1c545b90 [0x3bfb1100]>{type = mutable dict, count = 1,
entries =>
6 : <CFString 0x1c545bc0 [0x3bfb1100]>{contents = "ApplicationType"} = <CFString 0x1c545b30 [0x3bfb1100]>{contents = "User"}
}
Nov 29 20:49:57  mc_mobile_tunnel[267] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:49:57  mc_mobile_tunnel[267] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:49:57  mc_mobile_tunnel[268] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:49:57  mc_mobile_tunnel[268] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:49:57  lockdownd[29] <Notice>: 2fe93000 set_response_error: handle_start_session SessionActive
Nov 29 20:49:57  lockdownd[29] <Notice>: 2fe93000 set_response_error: handle_start_session SessionActive
Nov 29 20:50:03  mc_mobile_tunnel[270] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:50:03  mc_mobile_tunnel[270] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:51:31  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_screen_off even though we are not in it, doing nothing
Nov 29 20:51:31  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableDetect 0
Nov 29 20:51:31  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableType Detached
Nov 29 20:51:31  kernel[0] <Debug>: virtual IOReturn AppleUSBDeviceMux::message(UInt32, IOService *, void *) - kMessageInterfaceWasDeActivated
Nov 29 20:51:31  kernel[0] <Debug>: AppleUSBDeviceMux::reportStats: USB mux statistics:
Nov 29 20:51:31  kernel[0] <Debug>: USB mux: 195 reads / 0 errors, 493 writes / 0 errors
Nov 29 20:51:31  kernel[0] <Debug>: USB mux: 0 short packets, 0 dups
Nov 29 20:51:31  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_charging even though we are not in it, doing nothing
Nov 29 20:51:31  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_screen_off even though we are not in it, doing nothing
Nov 29 20:51:31  ptpd[104] <Notice>: PTP interface has been deactivated.
Nov 29 20:51:41  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_asleep even though we are not in it, doing nothing
Nov 29 20:51:41  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableDetect 1
Nov 29 20:51:41  kernel[0] <Debug>: AppleD1881PMUPowerSource: AppleUSBCableType USBHost
Nov 29 20:51:41  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state unplugged_screen_off even though we are not in it, doing nothing
Nov 29 20:51:41  UserEventAgent[13] <Warning>: PLAggregateState Error: Leaving state pluggedin_screen_off even though we are not in it, doing nothing
Nov 29 20:51:41  ptpd[272] <Error>: ptpd: startResponder
Nov 29 20:51:41  kernel[0] <Debug>: launchd[272] Builtin profile: ptpd (sandbox)
Nov 29 20:51:42  ptpd[272] <Notice>: PTP interface has been activated at high speed.
Nov 29 20:51:43  lockdownd[29] <Notice>: 2ffcf000 verify_pair_record: The strings don't match. Is this really a UUID?
Nov 29 20:51:43  lockdownd[29] <Notice>: 2ffcf000 store_escrow_record: Creating escrow bag (hash=9263ecf9c114f3a5cecdf7a52df193b4ce25044f) for 30264900-17792825678462560
Nov 29 20:51:52  lockdownd[29] <Notice>: 01442000 verify_pair_record: The strings don't match. Is this really a UUID?
Nov 29 20:51:52  lockdownd[29] <Notice>: 01442000 store_escrow_record: Creating escrow bag (hash=9de39584e1758f58137d28e4bd8c2fd79b5ba0a2) for 30264900-1682617038156454252
Nov 29 20:51:53  lockdownd[29] <Notice>: 01442000 special_case_get: MGCopyAnswer(kMGQMobileEquipmentIdentifier) returned NULL
Nov 29 20:51:53  lockdownd[29] <Notice>: 01442000 copy_phonenumber: CTSettingCopyMyPhoneNumber() returned NULL
Nov 29 20:51:53  mobile_installation_proxy[275] <Error>: 0x3cbd7b88 MobileInstallationSlowLookupBreak: MobileInstallationBrowse was called without specifying an options dictionary containing kLookupReturnAttributesKey. This usage is inefficient and may cause performance problems. Break on MobileInstallationSlowLookupBreak to debug.
Nov 29 20:51:53  mobile_installation_proxy[275] <Error>: 0x3cbd7b88 MobileInstallationSlowLookupBreak: Existing options dictionary: <CFBasicHash 0x1c5119d0 [0x3bfb1100]>{type = mutable dict, count = 1,
entries =>
6 : <CFString 0x1c511a00 [0x3bfb1100]>{contents = "ApplicationType"} = <CFString 0x1c511970 [0x3bfb1100]>{contents = "User"}
}
Nov 29 20:51:53  mc_mobile_tunnel[277] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:51:53  mc_mobile_tunnel[277] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:51:53  mc_mobile_tunnel[278] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:51:53  mc_mobile_tunnel[278] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:51:55  mc_mobile_tunnel[280] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:51:55  mc_mobile_tunnel[280] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
Nov 29 20:52:01 iPhone4S mc_mobile_tunnel[282] <Notice>: (Note ) MC: mc_mobile_tunnel starting.
Nov 29 20:52:01 iPhone4S mc_mobile_tunnel[282] <Notice>: (Note ) MC: mc_mobile_tunnel shutting down.
EN

回答 2

Stack Overflow用户

发布于 2013-01-28 18:21:43

这是因为您可能会在关闭picker之后立即关闭视图:

代码语言:javascript
复制
[picker dismissModalViewControllerAnimated:YES];

[self dismissModalViewControllerAnimated:YES];

由于您已经使用了animated YES,选择器还没有被关闭,所以使用新的API

代码语言:javascript
复制
[picker dismissViewControllerAnimated:YES completion:^{
        [self dismissModalViewControllerAnimated:YES];
    }];
票数 0
EN

Stack Overflow用户

发布于 2013-01-28 18:36:21

应用程序崩溃是因为在iOS6中,[self dismissModalViewControllerAnimated:YES];是不推荐的,你用[picker dismissViewControllerAnimated:YES completion:nil];代替它可能会解决你的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14559271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档