Iphone UITextField只有整数 [英] Iphone UITextField only integer

查看:160
本文介绍了Iphone UITextField只有整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的IB中有一个UITextField,我想检查用户是否只输入数字(无字符)并获取整数值。



UITextField的整数值如下:

  int integer = [myUITexrtField.text intValue]; 

当我把一个字符(,;。)返回0,我不知道

解决方案
>

http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Objective-C



或者,您可以确保当焦点位于字段时,只有数字键盘出现


I have a UITextField in my IB and I want to check out if the user entered only numbers (no char)and get the integer value.

I get the integer value of the UITextField like that :

int integer = [myUITexrtField.text intValue];

When I put a character ( , ; . ) it return me 0 and I don't know how to detect that it is not only numbers.

How can I do?

解决方案

http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Objective-C

Or you could ensure that only the numeric keyboard appears when the focus comes on the field

这篇关于Iphone UITextField只有整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆