开发者

Add UITextField to cameraOverlay

开发者 https://www.devze.com 2023-03-28 03:45 出处:网络
Hi all I am trying to add a UITextField to my cameraOverlay. I am getting it to show up on my camera view, but it is not editable. Its not responding at all. What approach do I need to take to get it

Hi all I am trying to add a UITextField to my cameraOverlay. I am getting it to show up on my camera view, but it is not editable. Its not responding at all. What approach do I need to take to get it to repsond?

I 开发者_C百科have looked at this questions, but do not understand how to set a transparent View Controller on top of my cameraOverly.

Suggestion for camera overlay

Thanks in advance!


Steps should be:

  1. Create your picker.

  2. Create an empty view with clearColor background.

  3. Add your textfield with addSubview: to the view in step 2.

  4. Set cameraOverlayView to the view created in step 2.

  5. Present your picker.

In 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];

I typed the code here myself so it could have some typo, Hope it helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号