【发布时间】:2014-04-26 15:46:02
【问题描述】:
我希望在使用摄像机时能够向右滑动以隐藏摄像机控件。视图显示得很好,但是当我滑动时出现错误。
我收到以下错误:
VideoStream[13065:60b] -[UILayoutContainerView toggleControlsWithGesture]:发送到实例的无法识别的选择器 0x1701a1960 2014-04-26 11:37:28.639 VideoStream[13065:60b] * 由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'-[UILayoutContainerView toggleControlsWithGesture]:
代码如下:
- (BOOL)startCameraControllerFromViewController:(UIViewController *)controller usingDelegate:(id)delegate
{
if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil)
|| (controller == nil)) {
return NO;
}
_cameraUI = [[UIImagePickerController alloc] init];
_cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
_cameraUI.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
_cameraUI.allowsEditing = NO;
_cameraUI.delegate = delegate;
[controller presentViewController:_cameraUI animated:YES completion:nil];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]
initWithTarget:_cameraUI.view
action:@selector(toggleControlsWithGesture)];
swipeRight.delegate = self;
//And assuming the "Up" direction in your screenshot is no accident
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[_cameraUI.view addGestureRecognizer:swipeRight];
return YES;
}
这是刷卡码:
- (void)toggleControlsWithGesture
{
NSLog(@"BOOM");
if (_showsControls == YES) {
_cameraUI.showsCameraControls = NO;
} else {
_cameraUI.showsCameraControls = YES;
}
}
非常感谢您提供的任何帮助。
【问题讨论】:
-
...-initWithTarget:_cameraUI.view ...应该是initWithTarget:self即UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(toggleControlsWithGesture)];
标签: ios objective-c cocoa-touch uiimagepickercontroller uiswipegesturerecognizer