iPhone:从相机捕获视频后打开新的 View Controller

标签 iphone xcode

我想在按下停止视频捕获按钮后打开新的 View Controller 。 我正在使用这段代码,但我无法做到这一点。

-(void)shootvideo
    {


    UIImagePickerController *imagePicker =
    [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;


        imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;



        imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];

    [self presentModalViewController:imagePicker animated:YES];


    }




    -(void) imagePickerController: (UIImagePickerController *) picker
    didFinishPickingMediaWithInfo: (NSDictionary *) info 
    {

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];

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

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

           NSURL *videoUrl=(NSURL*)[info objectForKey:UIImagePickerControllerMediaURL];


         if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
         UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
         }
         }


         [self dismissModalViewControllerAnimated:YES];

         // nextviewcontroller *test=[[nextviewcontroller alloc]init];

     //[self.navigationController pushViewController:test animated:YES];




         }

    }

按下停止捕获视频按钮后,我想导航到另一个 View 。

最佳答案

您已经通过 presentModalViewcontroller 呈现了图像选择器,因此您无法在图像选择器上调用 [self.navigationController PushViewController:testanimated:YES]; 。您有两种选择,一种是简单的

1) 无需在图像选择器上调用 [selfmissModalViewControllerAnimated:YES];,只需调用

   nextviewcontroller *test=[[nextviewcontroller alloc]init];
   [self presentModalViewController:nextviewcontroller animated:YES];

2) 使用委托(delegate)调用新的 View Controller 。

关于iPhone:从相机捕获视频后打开新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10656334/

相关文章:

ios - 使用本地通知 ios 打开 url

ios - 更新 CoreData 实体或保存一个新实体

ios - Xcode - 如何添加可以在头文件中检查的标志?

xcode - 如何使用远程 Git 存储库设置 Xcode

iphone - UITextView 中的两列文本?

android - iOS 允许无效证书,而 android 不允许

iphone - 屏幕旋转处理ios

iphone - 旋转 PNG 文件

ios - 在 Swift 中使用 SPUserResizableView

iphone - 如何以非阻塞延迟执行多个操作?