2016-04-25 34 views
0

我想用UIImagePickerController來拍照並禁用縮放捏功能,而我在做一個[picker addSubView:myOverlay]時不阻擋相機控制。所以我創建了下面的「myOverlayView」類,希望攔截所有觸摸,以便我的UIImagePickerController相機控件不受影響。如何禁用縮放並保持對UIImagePickerController的控制?

(每本教程:https://josee.me/2011/02/16/overlaying-the-iphone-camera-without-blocking-its-controls/

// implement UIView Class... 
@implementation myOverlayView : UIView 

- (id)initWithFrame:(CGRect)frame { 
    if (self = [super initWithFrame:frame]) { 
     self.opaque = NO; 
     self.backgroundColor = [UIColor clearColor]; 
    } 
    return self; 
} 

- (BOOL)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 
    NSLog(@"hitTest....hit"); 
    return nil; 
} 

@end 

// Call Camera... 
picker.delegate = self; 
picker.allowsEditing = NO; 
picker.sourceType = UIImagePickerControllerSourceTypeCamera; 

myOverlayView *myOverlayView1 = [[myOverlayView alloc]init]; 

[picker.view addSubview:myOverlayView1]; 


[self presentViewController:picker animated:YES completion:NULL]; 

的則hitTest:事件方法被擊中,並覆蓋已加入後進行變焦捏仍然有效。 我錯過了什麼?

+0

你沒有指定你發佈的代碼有什麼問題。 – rmaddy

回答

2

爲什麼不嘗試以下操作:將UIPinchGestureRecognizer添加到疊加層中,並設置*pinchGesture.cancelsTouchesInView = YES?還沒有嘗試過,但應該能夠攔截拾取器的夾捏。

相關問題