关于wxPython的textCtrl怎样限制输入字符的搜索推荐
1个回答
2016-07-22
展开全部
//创建
1.
phonetext = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width-width, 25)];
...... //设置相关属性
2.关联上selector. 注意: 事件要forControlEvents:UIControlEventEditingChanged
[phonetext addTarget:self action:@selector(changePhoneNumValue) forControlEvents:UIControlEventEditingChanged];//手机号码
3.实现selector
-(void)changePhoneNumValue
{
int MaxLen = 15;
NSString* szText = [phonetext text];
if ([phonetext length]> MaxLen)
{
phonetext.text = [szText substringToIndex:MaxLen];
}
}
1.
phonetext = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width-width, 25)];
...... //设置相关属性
2.关联上selector. 注意: 事件要forControlEvents:UIControlEventEditingChanged
[phonetext addTarget:self action:@selector(changePhoneNumValue) forControlEvents:UIControlEventEditingChanged];//手机号码
3.实现selector
-(void)changePhoneNumValue
{
int MaxLen = 15;
NSString* szText = [phonetext text];
if ([phonetext length]> MaxLen)
{
phonetext.text = [szText substringToIndex:MaxLen];
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询