IOSDevelop applicationsVideo RecordingThe instance is the content to be introduced in this article. This section uses Apple's own cameraVideoThe code is shared by CocoaChina member "1056975026", which helps developers who use the photo and video functions in the developed applications.
- (Void) choosePhotoBySourceType: (UIImagePickerControllerCameraCaptureMode) sourceType
- {
- M_imagePickerController = [[[UIImagePickerController alloc] init] autorelease];
- M_imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
- M_imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- M_imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
- // M_imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
- NSArray * sourceTypes = [UIImagePickerController availableMediaTypesForSourceType: m_imagePickerController.sourceType];
- If ([sourceTypes containsObject :( NSString *) kUTTypeMovie])
- {
- M_imagePickerController.mediaTypes = [NSArray arrayWithObjects :( NSString *) kUTTypeMovie, (NSString *) kUTTypeImage, nil];
- }
- // M_imagePickerController.cameraCaptureMode = sourceType;
- // M_imagePickerController.mediaTypes
- // ImagePickerController. allowsEditing = YES;
- [Self presentModalViewController: m_imagePickerController animated: YES];
- }
- -(Void) takePhoto
- {
- If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
- {
- [Self choosePhotoBySourceType: nil];
- }
- }
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- -(Void) viewDidLoad {
- [Super viewDidLoad];
- UIButton * takePhoto = [UIButton buttonWithType: UIButtonTypeRoundedRect];
- [TakePhoto setTitle: @ "video" forState: UIControlStateNormal];
- [TakePhoto addTarget: self action: @ selector (takePhoto) forControlEvents: UIControlEventTouchUpInside];
- TakePhoto. frame = CGRectMake (50,100,100, 30 );
- [Self. view addSubview: takePhoto];
Summary:IOSDevelop applicationsVideo RecordingI hope this article will help you with the introduction of the instance!