• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - 将 UITextField 添加到 cameraOverlay

[复制链接]
菜鸟教程小白 发表于 2022-12-13 08:48:36 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

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

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

Suggestion for camera overlay

提前致谢!



Best Answer-推荐答案


步骤应该是:

  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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap