Q1:UITextView行數(shù)判斷方式佃延?
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即將換行時(shí)夷磕,當(dāng)輸入中文會(huì)帶入拼音履肃,解決方案
- (void)textViewDidChange:(UITextView *)textView {
UITextRange *selectedRange = [textView markedTextRange];
NSString * newText = [textView textInRange:selectedRange];//獲取高亮部分
if(newText.length>0){
return;
}
//防止輸入時(shí)在中文后輸入英文過(guò)長(zhǎng)直接中文和英文換行
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轉(zhuǎn)字符串
double d = [number doubleValue];
NSString *dStr = [NSString stringWithFormat:@"%f", d];
NSDecimalNumber *dn = [NSDecimalNumber decimalNumberWithString:dStr];
label.text = [dn stringValue];
Q5:時(shí)間戳轉(zhuǎn)轉(zhuǎn)問(wèn)題
默認(rèn)是UTC 世界標(biāo)準(zhǔn)時(shí)間,需要轉(zhuǎn)換為本地時(shí)間
NSDate* date = [NSDate dateWithTimeIntervalSince1970: message.receivedTime/1000.0];
NSTimeZone zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate: date];
NSDate *localeDate = [date dateByAddingTimeInterval: interval];