标签:ios开发
1.不能滚动
self.scrollEnabled = NO;
[UIFont systemFontOfSize:30.0f]
[UIFont boldSystemFontOfSize:30.0f]
self.textContainerInset = UIEdgeInsetsMake(TEXTVIEW_TOP_INSET, TEXTVIEW_LEFT_INSET, TEXTVIEW_BOTTOM_INSET,TEXTVIEW_RIGHT_INSET);
[self becomeFirstResponder];
[self setEditable:YES];
7.限制输入长度
按照这个思路,即 将要生成的文本长度 = 原始文本长度 - 选中文本长度 + 输入文本长度。再考虑到删除的情况,我的代码如下: - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if ([text isEqualToString:@""] && range.length > 0) { //删除字符肯定是安全的 return YES; } else { if (textView.text.length - range.length + text.length > MAX_INPUT_LENGTH) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"超出最大可输入长度" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; return NO; } else { return YES; } } }
8.不能选中
[self setSelectable:YES];
标签:ios开发
原文地址:http://blog.csdn.net/neng18/article/details/43603351