菜鸟教程小白 发表于 2022-12-12 13:10:20

ios - 完成按钮单击时调用 UITextField 方法


                                            <p><p>我在 <code>UITableViewCell</code></p> 中有一个文本字段

<p>当我直接点击文本字段时,会调用此方法:</p>

<pre><code>-(void)editingChanged:(UITextField *)sender
</code></pre>

<p>这是我在 <code>cellForRowAtIndexPath</code></p> 中的代码

<pre><code>;


-(void) editingChanged:(UITextField *)sender
{
    NSLog( @&#34;text changed: %@&#34;,cell.ProductQuantityTextField.text);
    ;
}
</code></pre>

<p>我想要那个,当我点击文本字段然后我改变文本字段的值然后我点击键盘的完成按钮我想调用 <code>UITextField</code> 方法</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><code>shouldReturn</code> 委托(delegate)方法就是你要找的:</p>

<pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    // do something
    return YES;
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 完成按钮单击时调用 UITextField 方法,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42853564/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42853564/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 完成按钮单击时调用 UITextField 方法