菜鸟教程小白 发表于 2022-12-11 19:18:48

ios - 如何将添加文本框合并到 navigationItem -> rightBarButtonItem?


                                            <p><p>我想在我的 rightBarButtonItem 中加入一个添加文本框,以便在单击 rightBarButtonItem 时提示用户输入标题名称。这是为了给 TableViewController 类添加新的单元格名称。到目前为止,我的代码所做的只是添加没有自定义名称的新单元格。</p>

<p>到目前为止,这是我的代码:</p>

<pre><code>override func viewDidLoad() {
    super.viewDidLoad()

self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: &#34;generate new item&#34;, style: .plain, target: self, action: #selector(TableViewController.insert))

}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果您使用默认导航栏,我的意思是在您的应用中显示默认导航栏,然后先隐藏导航栏。并使用 <code>UIView</code> 创建您自己的导航栏,导航栏高度相同(即 64),并将 <code>UITextField</code> 添加到该 View 。</p>

<p>这是您可以将文本字段添加到导航栏的唯一选项。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何将添加文本框合并到 navigationItem -&gt; rightBarButtonItem?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42895020/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42895020/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何将添加文本框合并到 navigationItem -&gt; rightBarButtonItem?