Commit 6f8cc5c6 authored by zhangzhe's avatar zhangzhe

修改bug

parent 93816a26
......@@ -28,6 +28,9 @@ class SHInputController: SHBaseViewController
/// 未填写标题时的默认标题
private let defaultTitle: String = "新建笔记"
/// 标题
private var inputTitle: String = ""
/// 计时器
let timer = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue.global())
......@@ -189,6 +192,8 @@ class SHInputController: SHBaseViewController
// 显示记录
self.shInputView.textView.attributedText = self.viewModel.getAttributedStringWithSHRecordModel(recordModel: self.dataModel)
self.inputTitle = self.dataModel.rename
self.initPlayer()
// 修改音频时间, 保存一次
......@@ -361,14 +366,20 @@ class SHInputController: SHBaseViewController
self.dataModel.imagesPath = imageArray.imagesPathArray
self.dataModel.imagesIndex = imageArray.imagesIndexArray
if self.dataModel.rename.length == 0
if self.inputTitle.length == 0
{
self.dataModel.rename = defaultTitle
self.shInputView.textView.text = self.dataModel.rename
self.inputTitle = defaultTitle
self.shInputView.textView.text = defaultTitle
}
else
{
self.dataModel.rename = inputTitle
}
self.dataModel.txt = self.shInputView.textView.text.substring(self.dataModel.rename.length, length: self.shInputView.textView.text.length - self.dataModel.rename.length) ?? ""
self.dataModel.txt = self.shInputView.textView.text.substring(self.inputTitle.length, length: self.shInputView.textView.text.length - self.inputTitle.length) ?? ""
// 是否有录音都传, 用它来做为唯一表示
self.dataModel.pathFile = self.viewModel.documentFilePath + RecordMp3
......@@ -458,7 +469,7 @@ class SHInputController: SHBaseViewController
}
do {
let documentsFile = DocumentPath + self.viewModel.documentFilePath + "/\(self.dataModel.rename).pdf"
let documentsFile = DocumentPath + self.viewModel.documentFilePath + "/\(self.inputTitle).pdf"
try PDFGenerator.generate(self.shInputView.textView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加
......@@ -520,12 +531,16 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
{
// let selectedRange = textView.markedTextRange;
//
// if !(selectedRange?.isEmpty ?? false)
// if selectedRange == nil || selectedRange!.isEmpty
// {
//// if self.hasEmoji(text: text)
//// {
//// return false
//// }
// }
// else
// {
// if self.hasEmoji(text: text)
// {
// return false
// }
//
// }
if text.isContainEmoji()
......@@ -534,7 +549,7 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
}
// 获取标题文字位置
let titleRange = NSRange(location: 0, length: self.dataModel.rename.length)
let titleRange = NSRange(location: 0, length: self.inputTitle.length)
// 在标题位置输入的内容为标题
if range.location <= titleRange.location + titleRange.length
......@@ -555,7 +570,7 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
textViewString.insert(text, at: range.location)
// 保存标题文字
self.dataModel.rename = textViewString.substring(with: NSRange(location: 0, length: range.location + text.length))
self.inputTitle = textViewString.substring(with: NSRange(location: 0, length: range.location + text.length))
}
}
else
......@@ -665,7 +680,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
// 如果没有标题添加默认标题
if self.dataModel.rename.length == 0
if self.inputTitle.length == 0
{
// 标题
let titleString = NSMutableAttributedString(string: self.defaultTitle, attributes: (self.viewModel.titleAttributes() as! [NSAttributedString.Key : Any]))
......@@ -673,7 +688,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
self.shInputView.placeholder.isHidden = true
self.dataModel.rename = titleString.string
self.inputTitle = titleString.string
}
// 如果占位文字未隐藏, 隐藏占位文字
......
......@@ -30,11 +30,3 @@ class SHInputTextView: UITextView {
}
}
}
extension SHInputTextView: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment