<s:textfield>中的s代表什么?这个标签是干什么用的?
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
展开全部
两个代理方法 一个是点击return 缩回键盘
还有一个是对textField的输入进行监听
前提是需要对textField进行代理监听
//UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField;
{
//用户结束输入
[textField resignFirstResponder];
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange NSRange)range replacementString NSString*)string // return NO to not change text
{
//判断是否超过 ACCOUNT_MAX_CHARS 个字符,注意要判断当string.leng>0
//的情况才行,如果是删除的时候,string.length==0
int length = textField.text.length;
if (length >= ACCOUNT_MAX_CHARS && string.length >0)
{
return NO;
}
NSCharacterSet *cs;
cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];
NSString *filtered =
[[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
BOOL basic = [string isEqualToString:filtered];
return basic;
}
还有一个是对textField的输入进行监听
前提是需要对textField进行代理监听
//UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField;
{
//用户结束输入
[textField resignFirstResponder];
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange NSRange)range replacementString NSString*)string // return NO to not change text
{
//判断是否超过 ACCOUNT_MAX_CHARS 个字符,注意要判断当string.leng>0
//的情况才行,如果是删除的时候,string.length==0
int length = textField.text.length;
if (length >= ACCOUNT_MAX_CHARS && string.length >0)
{
return NO;
}
NSCharacterSet *cs;
cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];
NSString *filtered =
[[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
BOOL basic = [string isEqualToString:filtered];
return basic;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询