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
420
ノートアプリに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
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
For a Future-Friendly Web
brad_frost
179
9.8k
Scaling GitHub
holman
459
140k
Faster Mobile Websites
deanohume
307
31k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
A better future with KSS
kneath
239
17k
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をスタックする
もっと細かい コードは 書くよ!