菜鸟教程小白 发表于 2022-12-13 08:48:36

iphone - 将 UITextField 添加到 cameraOverlay


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

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

<p> <a href="https://stackoverflow.com/questions/6362516/suggestion-for-camera-overlay" rel="noreferrer noopener nofollow">Suggestion for camera overlay</a> </p>

<p>提前致谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>步骤应该是:</p>

<ol>
<li><p>创建您的选择器。</p></li>
<li><p>创建一个带有 clearColor 背景的空 View 。</p></li>
<li><p>使用 addSubview: 将您的文本字段添加到第 2 步中的 View 中。</p></li>
<li><p>将 cameraOverlayView 设置为步骤 2 中创建的 View 。</p></li>
<li><p>出示您的选择器。</p></li>
</ol>

<p>在代码中:</p>

<pre><code>//self.picker and self.textField being your UIImagePickerController and UITextField instances.
emptyView = [ initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen...
emptyView.backgroundColor = ;
; //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.
;
self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more..
;
;
;
</code></pre>

<p>我自己在这里输入了代码,所以它可能有一些错字,希望它有帮助! </p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 将 UITextField 添加到 cameraOverlay,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7053858/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7053858/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 将 UITextField 添加到 cameraOverlay