协议:<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
-(IBAction)fbShareVideo:(id)sender{
UIImagePickerController * pick = [[UIImagePickerController alloc] init];
pick.delegate = self;
pick.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
pick.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];//设置媒体种类
[self presentViewController:pick animated:YES completion:nil];
NSLog(@"zoulama,class-%@-->%@",self,self.picker);
}
//----方法1
//成功获得相片还是视频后的回调
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
__weak typeof(self) weakSelf = self;
NSURL *videoURL = [info objectForKey:UIImagePickerControllerReferenceURL];
NSLog(@"kong d:-->%@",videoURL);
[[Platform defaultPlatform] fbShareVideoUrl:videoURL completion:^(NSDictionary *resultData, NSError *error, BOOL isCancle) {
NSLog(@"sdk fbShare completed share:%@\n error:%@,iscancle:%zd", resultData,error,isCancle);
[self performSelector:@selector(closeThePick:) withObject:picker afterDelay:0 inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, nil]];
}];
}
- (void)closeThePick:(UIImagePickerController *)picker{
NSLog(@"=---------");
NSLog(@"2zoulama,class-%@-->%@",self,self.picker);
[picker dismissViewControllerAnimated:YES completion:nil];
}
- (void)fbShare:(NSURL *)videoURL{
[[Platform defaultPlatform] fbShareVideoUrl:videoURL completion:^(NSDictionary *resultData, NSError *error, BOOL isCancle) {
NSLog(@"sdk fbShare completed share:%@\n error:%@,iscancle:%zd", resultData,error,isCancle);
// [weakSelf closeThePick];
}];
}
//方法2
//成功获得相片还是视频后的回调
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSURL *videoURL = [info objectForKey:UIImagePickerControllerReferenceURL];
NSLog(@"kong d:-->%@",videoURL);
[picker dismissViewControllerAnimated:YES completion:^{
[self performSelector:@selector(fbShare:) withObject:videoURL afterDelay:0 inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, nil]];
}];
}
- (void)fbShare:(NSURL *)videoURL{
[[Platform defaultPlatform] fbShareVideoUrl:videoURL completion:^(NSDictionary *resultData, NSError *error, BOOL isCancle) {
NSLog(@"sdk fbShare completed share:%@\n error:%@,iscancle:%zd", resultData,error,isCancle);
}];
}