我正在使用UIImagePickerController
(Xcode - 版本6.2(6C131e),iOS SDK 8.0及更高版本)来捕获iPad应用程序中的视频和照片。媒体捕获部分工作正常。但我面临三个奇怪的问题。无论有没有自动布局,我都会遇到这些问题,并且只允许所有方向和风景。
在拍摄照片时或拍摄照片后,如果我按主页按钮并再次返回应用程序,则选择器界面会恢复到以前的状态捕获任何媒体。也就是说,它显示开始捕获按钮,切换相机按钮和取消按钮。只有取消按钮有效。除此之外,整个界面看起来很冷。只有当我按下取消并再次调出选择器时,我才能再次尝试捕捉。
每当我尝试呈现图像选择器时,都会弹出此警告
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
每当我尝试调出仅用于捕获视频的选择器时,我在控制台中收到以下消息
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x14de8a00 V:|-(10.5)-[CAMFlipButton:0x14defa40] (Names: '|':CAMBottomBar:0x14eed5a0 )>",
"<NSLayoutConstraint:0x14de56d0 CAMShutterButton:0x14ef1440.centerY == CAMBottomBar:0x14eed5a0.centerY>",
"<NSLayoutConstraint:0x14dcfdb0 'UIView-Encapsulated-Layout-Height' V:[PLImagePickerCameraView:0x153da800(0)]>",
"<NSLayoutConstraint:0x14dcc570 CAMBottomBar:0x14eed5a0.height == PLImagePickerCameraView:0x153da800.height>",
"<NSLayoutConstraint:0x14efbc50 V:[CAMFlipButton:0x14defa40]-(0)-[UIView:0x14ee64d0]>",
"<NSLayoutConstraint:0x14efbc80 UIView:0x14ee64d0.bottom == CAMShutterButton:0x14ef1440.top>"
)
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
所有这些都不会以任何方式影响捕获过程。但就用户体验而言,1会产生负面影响
我搜索过并发现有关2和3的问题在Stack Overflow上有问题,但没有一个解决方案适用于我
我使用以下代码:
UIImagePickerController *imagePickerController;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
switch (mediaType)
{
case 0:
[imagePickerController setCameraCaptureMode:UIImagePickerControllerCameraCaptureModePhoto];
break;
case 1:
{
NSArray *mediaTypeArray = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
[imagePickerController setMediaTypes:mediaTypeArray];
break;
}
default:
break;
}
imagePickerController.delegate = self;
}
[self presentViewController:imagePickerController animated:YES completion:nil];
希望有人遇到类似的问题,因为这是一个非常基本的操作。请帮忙。
答案 0 :(得分:0)
它似乎在苹果方面,我们无能为力。幸运的是,除了在调试器中烦人之外,它不会导致与用户相关的问题。