Life, Education, Death

プログラミング以外でも思ったことをつらつらと書きたい

ゾンビになっているUITapGestureRecognizerを倒した

状況を説明すると

BのViewControllerでUITapGestureRecognizerを使ってUIImageViewをタップしたら、特定の動作をするように対応していた。

1〜5の順番で遷移させていくと、5のタイミングでクラッシュした。

NSZombieEnabledを有効にしたら、下のようなログが出ている状況。

*** -[UITapGestureRecognizer retain]: message sent to deallocated instance 0xf33ec00

調べた限りだと、↓と同じ現象のようだ。
iphone - Crash when using gesture recognizers in StoryBoard - Stack Overflow

Based on your steps to reproduce, this is a bug in UIKit. File a bug report. You can work around the bug by creating a strong outlet on SecondViewController and connecting it to the gesture recognizer. <del>Make sure you set the outlet to nil in viewDidUnload.</del>

ダミーでBのViewControllerにUITapGestureRecognizerのReferencing Outletsを接続して回避した。

UIKitのバグなのか、もっとスマートな回避方法があるかどうかがまだわかっていないが、一旦動いたのでこれでしばらくは・・・