- (void)limitTextViewTextLength{
NSString*toBeString =self.classNameTF.text;
NSArray *currentar = [UITextInputMode activeInputModes];
UITextInputMode*current = [currentarfirstObject];
if([current.primaryLanguageisEqualToString:@"zh-Hans"])
{
UITextRange*selectedRange = [self.classNameTFmarkedTextRange];
UITextPosition*position = [self.classNameTFpositionFromPosition:selectedRange.startoffset:0];
if(!position)
{
if(toBeString.length>4)
{
self.classNameTF.text= [toBeStringsubstringToIndex:4];
}
}
}
else
{
if(toBeString.length>4)
{
self.classNameTF.text= [toBeString substringToIndex:4];
}
}
}
网友评论