大家好,我正在尝试将 UITextField 添加到我的cameraOverlay 中。我让它显示在我的相机 View 中,但它不可编辑。它根本没有反应。我需要采取什么方法才能让它响应?
我已经看过这个问题,但不明白如何在我的cameraOverly上设置透明的 View Controller 。
提前致谢!
最佳答案
步骤应该是:
创建您的选择器。
创建一个具有clearColor背景的空 View 。
使用 addSubview: 将文本字段添加到步骤 2 中的 View 。
将cameraOverlayView设置为第2步中创建的 View 。
展示您的选择器。
在代码中:
//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/