小编reg*_*ian的帖子

视频在AVFoundation的相机开关上冻结

我制作了一款具有拍摄和保存视频功能的应用.我已经使用了AVFoundation,Apple的AVCam一直是我的向导.

我希望我能说清楚:
一切正常,直到我发布第一次处理AVCamCaptureManager的videoViewController(在AVCam中将是AVCamViewController).之后,当我再次创建它时,视频会在相机切换后立即冻结.即使重新运行也无济于事,也无法清理或重置设备.(有时候其中一件事有所帮助,但这不是一条规则).

我不需要保存内存时释放videoViewController.

切换摄像头的代码与AVCam基本相同:

NSError *error;
AVCaptureDeviceInput *newVideoInput;
AVCaptureDevicePosition position = currentVideoInput.device.position;

if (position == AVCaptureDevicePositionBack)
    newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:frontFacingCamera error:&error];
else if (position == AVCaptureDevicePositionFront)
    newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:backFacingCamera error:&error];

if (newVideoInput != nil) {
    [session beginConfiguration];
    [session removeInput:currentVideoInput];
    if ([session canAddInput:newVideoInput]) {
        [session addInput:newVideoInput];
        [self setVideoInput:newVideoInput];
} else {
    [session addInput:currentVideoInput];
}
    [session commitConfiguration];
    [newVideoInput release];
} else if (error) {
    NSLog(@"%@",[error localizedDescription]);
}
Run Code Online (Sandbox Code Playgroud)

用于解除videoView的代码

[self.videoViewController.view removeFromSuperview];
self.videoViewController = nil;
Run Code Online (Sandbox Code Playgroud)

我目前的"解决方法"是简单地保留它,即使我不需要它.

有人可以解释为什么会发生这种情况以及如何解决它.

编辑:已解决 …

objective-c avfoundation ios4 ipad-2

6
推荐指数
2
解决办法
4905
查看次数

MPVolumeView和iOS 5

我正在尝试制作一个滑块来控制设备音量.以前我用MPVolumeView完成了这个,但是从iOS 5开始我在构建时遇到以下错误:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_MPVolumeView", referenced from:
  objc-class-ref in PlayerViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我是什么问题或者是否有其他方法来控制设备音量.

提前致谢!

volume objective-c ios mpvolumeview ios5

3
推荐指数
1
解决办法
2428
查看次数

标签 统计

objective-c ×2

avfoundation ×1

ios ×1

ios4 ×1

ios5 ×1

ipad-2 ×1

mpvolumeview ×1

volume ×1