Q1:UITextView行数判断方式?
float rows = round((_textView.contentSize.height - _textView.textContainerInset.top - _textView.textContainerInset.bottom) / _textView.font.lineHeight);
Q2:Cell随UITextView高度变化而变化,UITableView刷新方式
[tableView beginUpdates];
[tableView endUpdates];
Q3:UITextView即将换行时,当输入中文会带入拼音,解决方案
- (void)textViewDidChange:(UITextView *)textView {
UITextRange *selectedRange = [textView markedTextRange];
NSString * newText = [textView textInRange:selectedRange];//获取高亮部分
if(newText.length>0){
return;
}
//防止输入时在中文后输入英文过长直接中文和英文换行
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
paragraphStyle.alignment = NSTextAlignmentRight;
NSDictionary *attributes = @{
NSFontAttributeName:MN_RegularFontOfSize(16.0f),
NSForegroundColorAttributeName:MN_HEXCOLOR(0x29292D),
NSParagraphStyleAttributeName:paragraphStyle
};
textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
}
Q4:doule转字符串
double d = [number doubleValue];
NSString *dStr = [NSString stringWithFormat:@"%f", d];
NSDecimalNumber *dn = [NSDecimalNumber decimalNumberWithString:dStr];
label.text = [dn stringValue];