菜鸟教程小白 发表于 2022-12-11 19:42:25

ios - 添加将包含输入的 UIView


                                            <p><p>所以基本上我有我创建的这个页面控制 View ,有人会在点击登录或注册按钮时进入。因此,当它转到该页面 View 时,我尝试在该页面上设置 UIView,以便用户可以输入所需的信息。</p>

<p>下面的代码是我实现它的方式。请注意,此功能是注册按钮的目标。所以即使运行这个没有框出现?有什么见解吗?</p>

<pre><code> func regSegue() {
    let page = UIPageViewController()
    page.view.backgroundColor = UIColor .white; //Set to any color.
    present(page, animated: true, completion: nil)

// will create an inputs container view so users can enter credentials to register

    let regContainerView = U
    regContainerView.backgroundColor = UIColor.red

    regContainerView.translatesAutoresizingMaskIntoConstraints = false
    present(regContainerView, animated: true, completion: nil)

//need x,y,width, and height

    regContainerView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

   regContainerView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true

    regContainerView.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -24).isActive = true

    regContainerView.heightAnchor.constraint(equalToConstant: 150).isActive = true

}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>var txtField: UITextField = UITextField(frame: CGRect(x: 0, y: 0, width: 500.00, height: 30.00));

self.view.addSubview(txtField)
</code></pre>

<p>这就是您如何将一个添加到您的 View .. 只是一个例子。
希望你能有一个想法并按照自己的方式去做。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 添加将包含输入的 UIView,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44075394/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44075394/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 添加将包含输入的 UIView