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
280
ノートアプリに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
570
iPhone が数秒おきにクラッシュするんだけど!
watura
0
6
Swift Scripting入門
watura
0
120
2つのAuroraクラスタを同期したお話
watura
0
1.6k
Zaim API
watura
1
700
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
Being A Developer After 40
akosma
89
590k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
31
2.1k
RailsConf 2023
tenderlove
29
1k
Gamification - CAS2011
davidbonilla
80
5.1k
Agile that works and the tools we love
rasmusluckow
328
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
4 Signs Your Business is Dying
shpigford
182
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
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をスタックする
もっと細かい コードは 書くよ!