简体   繁体   English

如何在iPhone上触发相机捕捉的方法

[英]How to fire a method on camera capture click in iphone

I am working on a iPhone application which has a main functionality video capture. 我正在开发一个具有视频捕获功能的iPhone应用程序。 How can I fire a method when a user started video recording ?? 用户开始录制视频时,如何触发方法?

UIImagePickerController Class reference has instant method for image capturing, start and stop video recording. UIImagePickerController类参考具有用于图像捕获,启动和停止视频记录的即时方法。

Below is the copy of apple Doc for UIImagePickerController Class. 以下是Apple Doc for UIImagePickerController类的副本。

startVideoCapture Starts video capture using the camera specified by the UIImagePickerControllerCameraDevice property. startVideoCapture使用UIImagePickerControllerCameraDevice属性指定的摄像机开始视频捕获。

  • (BOOL)startVideoCapture Return Value YES on success or NO on failure. (BOOL)startVideoCapture返回值:成功则为YES,失败则为NO。 This method may return a value of NO for various reasons, among them the following: 由于多种原因,此方法可能返回NO值,其中包括:

Movie capture is already in progress The device does not support movie capture The device is out of disk space Discussion Use this method in conjunction with a custom overlay view to initiate the programmatic capture of a movie. 电影捕获已经在进行中该设备不支持电影捕获该设备磁盘空间不足讨论将此方法与自定义覆盖视图结合使用可以启动电影的程序化捕获。 You can take more than one movie without leaving the interface, but to do so requires you to hide the default image picker controls. 您可以在不离开界面的情况下拍摄多部电影,但是要这样做,需要隐藏默认的图像选择器控件。

Calling this method while a movie is being captured has no effect. 在捕获影片时调用此方法无效。 You must call the stopVideoCapture method, and then wait until the associated delegate object receives an imagePickerController:didFinishPickingMediaWithInfo: message, before you can capture another movie. 您必须先调用stopVideoCapture方法,然后等到关联的委托对象收到imagePickerController:didFinishPickingMediaWithInfo:消息后,才能捕获另一部电影。

Calling this method when the source type of the image picker is set to a value other than UIImagePickerControllerSourceTypeCamera results in the throwing of an NSInvalidArgumentException exception. 当图像选择器的源类型设置为UIImagePickerControllerSourceTypeCamera以外的值时,调用此方法将导致抛出NSInvalidArgumentException异常。

If you require additional options or more control over movie capture, use the movie capture methods in the AV Foundation framework. 如果您需要其他选项或对影片捕获有更多控制,请使用AV Foundation框架中的影片捕获方法。 Refer to AV Foundation Framework Reference. 请参考《 AV Foundation框架参考》。

Availability Available in iOS 4.0 and later. 可用性在iOS 4.0及更高版本中可用。 Declared In UIImagePickerController.h stopVideoCapture Stops video capture. 在UIImagePickerController.h中声明stopVideoCapture停止视频捕获。

  • (void)stopVideoCapture Discussion After you call this method to stop video capture, the system calls the image picker delegate's imagePickerController:didFinishPickingMediaWithInfo: method. (void)stopVideoCapture讨论调用此方法停止视频捕获后,系统将调用图像选择器委托的imagePickerController:didFinishPickingMediaWithInfo:方法。

Availability Available in iOS 4.0 and later. 可用性在iOS 4.0及更高版本中可用。 Declared In UIImagePickerController.h 在UIImagePickerController.h中声明

You can also get this from Apple Doc class ref 您也可以从Apple Doc类参考中获得此信息

when You click on camera recoding . 当您单击相机记录时。

After that you can check by 之后,您可以检查

If ([imagePickerController startVideoCapture] == yes)
{
   // Fire your method here.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM