iphone - 将 UITextField 添加到cameraOverlay

标签 iphone ios ios4 iphone-sdk-3.0

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

我已经看过这个问题,但不明白如何在我的cameraOverly上设置透明的 View Controller 。

Suggestion for camera overlay

提前致谢!

最佳答案

步骤应该是:

  1. 创建您的选择器。

  2. 创建一个具有clearColor背景的空 View 。

  3. 使用 addSubview: 将文本字段添加到步骤 2 中的 View 。

  4. 将cameraOverlayView设置为第2步中创建的 View 。

  5. 展示您的选择器。

在代码中:

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

我自己在此处输入了代码,因此可能存在一些拼写错误,希望有帮助!

关于iphone - 将 UITextField 添加到cameraOverlay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7053858/

相关文章:

ios - 解析Twitter登录-选择哪个Twitter帐户

ios - 如何以编程方式在 iOS 11+ 中打开设置 > 隐私 > 定位服务?

iphone - 从通讯录中获取号码

iphone - 如何从 iPod 应用程序播放音乐,同时仍在应用程序中接收远程控制事件?

iphone - 第二次将 uiimage 转换为负色会使应用程序崩溃

iphone - 从 NSString 中删除前导和尾随的换行符

ios - UIButton角半径与背景图片

ios - NSMutableSet 与自定义 isEqual : and hash callbacks

ios - 缺少两个 dylib,但没有 Xcode 链接错误

ios4 - xcode4 “dyld: Symbol not found: _OBJC_CLASS_$_AVCaptureDevice”错误