将UITextField添加到cameraOverlay

时间:2011-08-13 23:05:08

标签: iphone ios ios4 iphone-sdk-3.0

大家好我正在尝试将UITextField添加到我的cameraOverlay中。我将它显示在我的相机视图上,但它不可编辑。它根本没有回应。我需要采取什么方法才能让它成为代表?

我已经看过这些问题了,但是不明白如何在我的相机上设置透明的视图控制器。

Suggestion for camera overlay

提前致谢!

1 个答案:

答案 0 :(得分:3)

步骤应该是:

  1. 创建您的选择器。

  2. 使用clearColor background创建一个空视图。

  3. 将带有addSubview的文本字段添加到步骤2中的视图。

  4. 将cameraOverlayView设置为在步骤2中创建的视图。

  5. 展示您的选择器。

  6. 在代码中:

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

    我自己在这里键入了代码,所以它可能会有一些拼写错误,希望它有所帮助!