菜鸟教程小白 发表于 2022-12-12 14:46:43

ios - 什么值会在文本字段上显示为无穷大?


                                            <p><p>我有这个显示为无穷大的文本字段。</p>

<p> <img src="/image/wE6Ln.png" alt="enter image description here"/> </p>

<p>当我将此值读取到变量时,它显示为 <code>+inf</code> 但假设我将此 textField 更改为另一个值。我应该在 textField 上键入什么值才能使其再次无限?</p>

<p>此文本字段使用带有 2 个小数位和 1 个有效数字的数字 NSFormatter。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果用户键入您想显示为无穷大的内容,我会覆盖 - <code>textField:shouldChangeCharactersInRange:replacementString:</code> <code>UITextFieldDelegate</code> 方法返回 <code>NO </code> 并在那之前做了 <code></code> 。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 什么值会在文本字段上显示为无穷大?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29146024/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29146024/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 什么值会在文本字段上显示为无穷大?