Ios 委托文本字段,并将其限制为仅输入数字
我正在以编程方式创建一些Ios 委托文本字段,并将其限制为仅输入数字,ios,objective-c,delegates,uitextfield,Ios,Objective C,Delegates,Uitextfield,我正在以编程方式创建一些UITextFields,当我尝试委派它们时,我收到以下警告: NAVPlanViewController*const\u strong'到不兼容类型的参数id 在我的类的.c中,我添加了@界面NAVPlanViewController:UIViewController。 此外,我需要限制文本字段仅接受数字,我本想用此代码执行此操作,但由于UITextField不会Delegate我无法检查它: - (BOOL)textField:(UITextField *)textF
UITextField
s,当我尝试委派它们时,我收到以下警告:
NAVPlanViewController*const\u strong'到不兼容类型的参数id
在我的类的.c
中,我添加了@界面NAVPlanViewController:UIViewController
。
此外,我需要限制文本字段仅接受数字,我本想用此代码执行此操作,但由于UITextField
不会Delegate
我无法检查它:
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string {
if (!string.length) {
return YES;
}
if ([string rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet]
invertedSet]].location != NSNotFound){
//do something;
return NO;
}
在
NAVPlanViewController
界面定义中,
应该是
在NAVPlanViewController
界面定义中,
应该是
在NAVPlanViewController
界面定义中,
应该是
在您的NAVPlanViewController
界面定义中,
应该是
@neilco是正确的
@interface YourViewController ()<UITextFieldDelegate>
{
}
@end
@尼尔科是对的
@interface YourViewController ()<UITextFieldDelegate>
{
}
@end
@尼尔科是对的
@interface YourViewController ()<UITextFieldDelegate>
{
}
@end
@尼尔科是对的
@interface YourViewController ()<UITextFieldDelegate>
{
}
@end
请检查您要将UITextField替换为..@interface NAVPlanViewController:UIViewController的代理。请检查您要将UITextField替换为..@interface NAVPlanViewController:UIViewController的代理。请检查您要将UITextField替换为..@interface的代理NAVPlanViewController:UIViewController请检查您的代理是否要使用UITextField替换到…@interface NAVPlanViewController:UIViewController是的,我已经精疲力竭了,对此进行了全面概述。谢谢你确定你在设置代理吗?是的,我已经筋疲力尽了,完全忽略了这一点。谢谢你确定你在设置代理吗?是的,我已经筋疲力尽了,完全忽略了这一点。谢谢你确定你在设置代理吗?是的,我已经筋疲力尽了,完全忽略了这一点。谢谢你确定要设置代理吗?这在ipad上不起作用,因为它没有数字键盘,也可以粘贴字符(不是数字)。这在ipad上不起作用,因为它没有数字键盘,也可以粘贴字符(不是数字)。这在ipad上不起作用,因为它没有数字键盘,而且还可以粘贴字符(不是数字)。这在ipad上不起作用,因为它没有数字键盘,也可以粘贴字符(不是数字)。