2013-08-02 5 views
8

Sto tentando di aggiungere la visualizzazione overlay e spostare la funzionalità di scala & nell'immagine acquisita, ma non sono in grado di farlo a causa della vista di sovrapposizione.Spostamento e ridimensionamento non funzionanti quando overlayview è impostato sulla fotocamera

Ecco il mio codice:

-(void)showOverlayCamera 
{ 

UIImagePickerController *pickerObj = [[UIImagePickerController alloc] init]; 
pickerObj.delegate = self; 
pickerObj.allowsEditing = YES; 
pickerObj.sourceType = UIImagePickerControllerSourceTypeCamera; 

// creating overlayView 
UIView* overlayView = [[UIView alloc] initWithFrame:self.view.bounds]; 
UIImageView *logoImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo.png"]]; 
logoImgView.frame=CGRectMake(10, 10, 100, 20); 
[overlayView addSubview:logoImgView]; 

//add lable in overlay view 
UILabel *headerLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, logoImgView.frame.origin.y+logoImgView.frame.size.height+10, 250, 40)]; 
[email protected]"New Scan"; 
headerLabel.textColor=[UIColor whiteColor]; 
headerLabel.font=[UIFont fontWithName:@"Helvetica-Bold" size:40]; 
headerLabel.backgroundColor=[UIColor clearColor]; 
[overlayView addSubview:headerLabel]; 

//add square image in overlay view 
squareImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cameraBorder.png"]]; 
squareImgView.frame=CGRectMake(60, headerLabel.frame.origin.y+headerLabel.frame.size.height+20, 200, 200); 
[overlayView addSubview:squareImgView]; 

//adding lable in overlay view 
UILabel *instructionLabel=[[UILabel alloc]initWithFrame:CGRectMake(60, squareImgView.frame.origin.y+squareImgView.frame.size.height+5, 250, 60)]; 
instructionLabel.numberOfLines=2; 
[email protected]"Focus your mole in the center of square"; 
instructionLabel.textColor=[UIColor whiteColor]; 
instructionLabel.font=[UIFont fontWithName:@"Helvetica" size:20]; 
instructionLabel.backgroundColor=[UIColor clearColor]; 
[overlayView addSubview:instructionLabel]; 

[overlayView.layer setOpaque:NO]; 
overlayView.opaque = NO; 
//adding overlay view on camera 
[pickerObj setCameraOverlayView:overlayView]; 
[self presentViewController:pickerObj animated:YES completion:nil]; 
} 

risposta

3

Prova a fare sovrapposizione un'istanza di una sottoclasse UIView con hitTest override: withEvent :. Se non si desidera o uno qualsiasi dei suoi subviews a ricevere tocchi, sarebbe come questo:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 
    return nil; 
} 
+0

sì johnyu, l'ho provato ma non funziona ancora –

+0

E senza quella finestra di sovrapposizione funziona tutto bene? Inoltre, hai provato a impostare userInteractionEnabled = NO su tutte le sottoview di overlay? – johnyu

+0

sì senza overlay tutto funziona bene.E ho provato tutti i subview userInteractionEnabled = NO; –

5

risposta Finalmente sto ottenendo. Creo sottoclasse UIView per overlayview e sovrascrivi il metodo seguente, ignorerà i tocchi su overlayView.

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 
{ 

return NO; 
}