菜鸟教程小白 发表于 2022-12-11 21:46:31

ios - 从不同的 xib 获取 UITextField 值


                                            <p><p>我知道如何从 <code>UITextField</code> 中获取文本,所以这不是问题。我的问题是如何从不同的 XIB 文件中获取其值?</p>

<p>例如:我的 <code>Form.xib</code> 中有一个名称文本字段,我试图从 <code>Chart.xib</code></p> 中提取该名称值</p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>使 <code>UItextField</code> 在其相应的 ViewController (假设是 ViewA)中成为 <strong>IBOutlet</strong> (@<code>property</code>) ..then ..</p>

<p>让我们说你想要 ViewB 中文本文件的值。</p>

<p>所以在 ViewB 中。</p>

<pre><code>ViewA *viewA = [initwithnibName:@&#34;ViewA&#34; bundle:nil];

NSString *textfieldtext = viewA.textfieldNamehere.text;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 从不同的 xib 获取 UITextField 值,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/9589692/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/9589692/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 从不同的 xib 获取 UITextField 值