2011-08-13 2 views
2

Salut tout J'essaie d'ajouter un UITextField à ma cameraOverlay. Je l'obtiens pour apparaître sur ma vue de caméra, mais ce n'est pas éditable. Il ne répond pas du tout. Quelle approche dois-je prendre pour l'obtenir à repsond?Ajouter UITextField à cameraOverlay

J'ai regardé ces questions, mais je ne comprends pas comment régler un contrôleur de vue transparent sur le dessus de mon appareil photo.

Suggestion for camera overlay

Merci à l'avance!

Répondre

3

Des mesures doivent être:

  1. Créez votre préparateur.

  2. Créez une vue vide avec l'arrière-plan clearColor.

  3. Ajoutez votre textfield avec addSubview: à la vue à l'étape 2.

  4. Set cameraOverlayView à la vue créée à l'étape 2.

  5. Présentez votre préparateur.

Dans le code:

//self.picker and self.textField being your UIImagePickerController and UITextField instances. 
emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen... 
emptyView.backgroundColor = [UIColor clearColor]; 
[emptyView setAlpha:1.0]; //I think it is not necessary, but it wont hurt to add this line. 
self.textField.frame = CGRectMake(100, 100, self.textField.frame.size.width, self.textField.frame.size.height); //Here you can specify the position in this case 100x 100y of your textField preserving the width and height. 
[emptyView addSubview:self.textField]; 
self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more.. 
[emptyView release]; 
[self presentModalViewController:self.picker animated:YES]; 
[self.picker release]; 

Je tapé le code ici moi-même il pourrait avoir une faute de frappe, espère que ça aide!

+0

Un homme génial! travaillé comme un charme. Il suffit de changer "transparentColor" en "clearColor". – Louie

+0

Code mis à jour, donc tout le monde peut l'utiliser. –

Questions connexes