I'm创造一些UITextField
小号编程,当我试图委派他们,我收到这样的警告:代表文本框,并限制只能输入数字
NAVPlanViewController * const的__strong”到不兼容的类型
id<UITextFieldDelegate>
的参数
textHeight = [[UITextField alloc] initWithFrame:CGRectMake(0, 120, 160, 40)];
[textHeight setDelegate:self];
,并在我的课的.c
我加入@interface NAVPlanViewController : UIViewController <UITextViewDelegate>
。 另外,我需要克制文本字段只接受数字,我想用这个代码做,而是因为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;
}
请检查您的代理要使用的UITextField替换成 .... ....接口NAVPlanViewController:UIViewController –
Ravindhiran