gpt4 book ai didi

iphone - 在 iPhone 的录像机中显示剩余时间

转载 作者:搜寻专家 更新时间:2023-10-30 20:10:05 27 4
gpt4 key购买 nike

我想在录像机上显示剩余时间。目前显示的是录音时间。我怎么能?

我的代码是:

UIImagePickerController*  Videopicker1 = [[UIImagePickerController alloc] init];
Videopicker1.delegate = self;
Videopicker1.sourceType = UIImagePickerControllerSourceTypeCamera;
Videopicker1.showsCameraControls = YES;
Videopicker1.videoQuality=UIImagePickerControllerQualityTypeLow;
Videopicker1.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; // kUTTypeMovie is actually an NSString.
Videopicker1.videoMaximumDuration = 30.0f; // limits video length to 30 seconds.
[self presentModalViewController:Videopicker1 animated:YES];

提前致谢。

最佳答案

在你的 VC.h 文件上

@interface VideoCaptureVC_iPhone : UIViewController
<UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
UIImagePickerController *picker;
NSTimer *videoTimer;

}

@property (nonatomic, retain) NSTimer *videoTimer;

在你的 vc.m 文件上

- (void)pickerCameraSnap:(id)sender{
NSLog(@"start camera capture and timer");
[picker startVideoCapture];
self.videoTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];
}

根据您的需要进行计算,并在适当的位置更改文本@"TimeRemaining"我已经为横向 View 旋转了文本!

-(void)changeValue{
UILabel *textNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
textNameLabel.center = CGPointMake(30,285);
textNameLabel.backgroundColor = [UIColor redColor];
textNameLabel.text = @"TimeRemaining";
textNameLabel.textColor = [UIColor whiteColor];
CGAffineTransform transformRotate = CGAffineTransformMakeRotation((M_PI / 2));
textNameLabel.transform = transformRotate;

UIView *myOverlay = [[UIView alloc] initWithFrame:self.view.bounds];
UIImage *overlayImg = [UIImage imageNamed:@"CameraOverlay"];
UIImageView *overlayBg;
overlayBg = [[UIImageView alloc] initWithImage:overlayImg];
[myOverlay addSubview:overlayBg];
[myOverlay addSubview:textNameLabel];
[picker setCameraOverlayView:myOverlay];
}

最后停止计时器

- (void)stopCamera:(id)sender{
NSLog(@"stop camera");
[self.videoTimer invalidate];

[picker stopVideoCapture];
[picker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
}

关于iphone - 在 iPhone 的录像机中显示剩余时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14137565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com