Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ShorthandMaster
Commits
6f8cc5c6
Commit
6f8cc5c6
authored
Sep 30, 2020
by
zhangzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
93816a26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
SHInputController.swift
ShorthandMaster/Input/Controller/SHInputController.swift
+28
-13
SHInputTextView.swift
ShorthandMaster/Input/View/SHInputTextView.swift
+0
-8
No files found.
ShorthandMaster/Input/Controller/SHInputController.swift
View file @
6f8cc5c6
...
...
@@ -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
.
renam
e
.
length
==
0
if
self
.
inputTitl
e
.
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
.
renam
e
.
length
)
??
""
self
.
dataModel
.
txt
=
self
.
shInputView
.
textView
.
text
.
substring
(
self
.
inputTitle
.
length
,
length
:
self
.
shInputView
.
textView
.
text
.
length
-
self
.
inputTitl
e
.
length
)
??
""
// 是否有录音都传, 用它来做为唯一表示
self
.
dataModel
.
pathFile
=
self
.
viewModel
.
documentFilePath
+
RecordMp3
...
...
@@ -458,7 +469,7 @@ class SHInputController: SHBaseViewController
}
do
{
let
documentsFile
=
DocumentPath
+
self
.
viewModel
.
documentFilePath
+
"/
\(
self
.
dataModel
.
renam
e
)
.pdf"
let
documentsFile
=
DocumentPath
+
self
.
viewModel
.
documentFilePath
+
"/
\(
self
.
inputTitl
e
)
.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
.
renam
e
.
length
)
let
titleRange
=
NSRange
(
location
:
0
,
length
:
self
.
inputTitl
e
.
length
)
// 在标题位置输入的内容为标题
if
range
.
location
<=
titleRange
.
location
+
titleRange
.
length
...
...
@@ -555,7 +570,7 @@ extension SHInputController: UITextViewDelegate, SHInputTextViewDelegate
textViewString
.
insert
(
text
,
at
:
range
.
location
)
// 保存标题文字
self
.
dataModel
.
renam
e
=
textViewString
.
substring
(
with
:
NSRange
(
location
:
0
,
length
:
range
.
location
+
text
.
length
))
self
.
inputTitl
e
=
textViewString
.
substring
(
with
:
NSRange
(
location
:
0
,
length
:
range
.
location
+
text
.
length
))
}
}
else
...
...
@@ -665,7 +680,7 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
// 如果没有标题添加默认标题
if
self
.
dataModel
.
renam
e
.
length
==
0
if
self
.
inputTitl
e
.
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
.
renam
e
=
titleString
.
string
self
.
inputTitl
e
=
titleString
.
string
}
// 如果占位文字未隐藏, 隐藏占位文字
...
...
ShorthandMaster/Input/View/SHInputTextView.swift
View file @
6f8cc5c6
...
...
@@ -30,11 +30,3 @@ class SHInputTextView: UITextView {
}
}
}
extension
SHInputTextView
:
UIScrollViewDelegate
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment