Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ノートアプリにUndo機能を実装! UndoManager導入ポイント
Search
watura
August 24, 2024
0
410
ノートアプリにUndo機能を実装! UndoManager導入ポイント
iOSDC 2024 LT
watura
August 24, 2024
Tweet
Share
More Decks by watura
See All by watura
Ruby note Mobile Tech Talk #1
watura
0
1k
iPhone が数秒おきにクラッシュするんだけど!
watura
0
7
Swift Scripting入門
watura
0
120
2つのAuroraクラスタを同期したお話
watura
0
1.6k
Zaim API
watura
1
710
Featured
See All Featured
Side Projects
sachag
455
42k
It's Worth the Effort
3n
184
28k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Git: the NoSQL Database
bkeepers
PRO
430
65k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
How to Ace a Technical Interview
jacobian
277
23k
Become a Pro
speakerdeck
PRO
28
5.4k
Rails Girls Zürich Keynote
gr2m
94
14k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Transcript
UndoManager導入ポイント ノートアプリにUndo機能を実装! watura note 株式会社 iOS アプリエンジニア https://wtr.app iOSDC 2024
LT
お疲れ さまです
Undo Manager
使って ます?
Undo Manager
iOS 3.0+
Undo/ Redoのた めの
スタック
ス
タ ス
ク タ ス
Undo
タ ス
ッ タ ス
ク ッ タ ス
後入 先出
にUndo機能を実装しようとして苦労した話 iOS版
使い方
register Undo(...) { } クを消す
UndoManager. undo()
Redo?
registerUndo { } クを消す registerUndo { クを入力 }
UndoManager. redo()
簡単!
最高!
Grouping
複数の
Undoを
1つの
Undoと みなす
便利 機能
一連の 文字入力
いっぺんに undoされる
謎のブロック ごと
iOSさんが
いい感じに
まとめて くれる
もちろん
手動でも 管理できる
beginUndoGrouping endUndoGrouping
beginUndoGrouping() undoTask("Undo 1") endUndoGrouping() beginUndoGrouping() undoTask("Undo 2") endUndoGrouping() beginUndoGrouping() undoTask("Undo
3") endUndoGrouping()
undo() → Undo3 undo() → Undo2 undo() → Undo1
ってなると 思うでしょ?
undo() → Undo3 Undo2 Undo1
みんな まとめて Undo!!!
iOSさんが Grouping いい感じに
無理やりwait をいれる スレッドとか
undo() → Undo3 undo() → Undo2 undo() → Undo1
全部
手動
groupsByEvent = false
beginUndoGrouping() undoTask("Undo 1") endUndoGrouping() beginUndoGrouping() undoTask("Undo 2") endUndoGrouping() beginUndoGrouping() undoTask("Undo
3") endUndoGrouping()
undo() → Undo3 undo() → Undo2 undo() → Undo1
beginを
忘れていたら
クラッシュ
クラッ シュ
まだまだ続くよ 問題点
UITextView
_UITextUndoManager
_UITextUndoManager
iOSっぽい テキストの Undo
Undoの 自動登録
override
undoに
登録されない
手動で 登録
iOSっぽい テキストの Undo
いい感じには 難しい
諦めた
固有の問題点
https://note.com/fromkk/n/ne14f81e62e3f
TextView ImageView TextView StackView エディタの構造
TextView1 TextView2 Undo Manager Undo Manager
TextView それぞれが
Undo Manager をもつ
TextView1 TextView2 変更3 変更1 変更2
Undoボタン 連打で
変更3 変更2 変更1
全部 戻したい
できない
Responder Chainが別
TextView1 TextView2 変更3 変更1 変更2 知らない子 ⇔
TextView1 TextView2 オレオレUndoManager
_UITextUndoManager
オレオレ UndoManager 作れない
通知が飛んで 来たら
UndoManger を スタックする
NSUndoManager DidCloseUndoGroup
UndoManager 1 (変更3) UndoManager 1 (変更1) UndoManager 2 (変更2) 上から取り出す
文字選択状態 カーソルの位置 テキスト以外の要素 要素をまたぐUndoG
気合い
あとはエディタに不 具合があったりして 大変だった
まだ不具合があると 思う ごめん。。。
UndoManagerはシンプルなスタッy registerUndo → undo()・redo(R 複数処理をまとめられるGroupins 勝手にいい感じにやってくれF
やめろ!な時 groupsByEvent = falsÄ begin・endGroupins beginをしわすれるとクラッシ _UITextUndoManagerを使わないとデフォルトと違う動X ResponderChain外への対Â UndoManagerは通知を飛ばしまくF 通知を見てUndoManagerをスタックする
もっと細かい コードは 書くよ!