3

我想在录像机上显示剩余时间。目前它正在显示录制时间。我怎样才能?

我的代码是:

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];

提前致谢。

4

2 回答 2

3

在您的 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”我已经为横向视图旋转了文本!

-(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];
}
于 2013-02-21T11:45:50.507 回答
0

由于您设置了视频最长时间,并且您声明您当前正在显示当前持续时间。

TimeRemaining = videoMaximumDuration - currentDuration; 
于 2013-01-03T11:26:17.777 回答