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
460
ノートアプリに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
1.3k
iPhone が数秒おきにクラッシュするんだけど!
watura
0
9
Swift Scripting入門
watura
0
120
2つのAuroraクラスタを同期したお話
watura
0
1.6k
Zaim API
watura
1
720
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
How STYLIGHT went responsive
nonsquared
100
5.8k
Designing for Performance
lara
610
69k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Why Our Code Smells
bkeepers
PRO
339
57k
Site-Speed That Sticks
csswizardry
10
820
Testing 201, or: Great Expectations
jmmastey
45
7.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
113
20k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
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をスタックする
もっと細かい コードは 書くよ!