回避策
回避策については、Apple Developer Forums で回答を見つけました。backgroundViewとselectedBackgroundViewの両方のケースを処理するために、その上に構築しました。
この問題は、製品版の iOS7.0.2 でもまだ見られます。ただし、この回避策は簡単で、問題を修正します(私にとって)。このコードをカスタム UITableViewCell サブクラスにドロップします。
この要点でも見つけることができます: https://gist.github.com/idStar/7018104
- (void)layoutSubviews {
[super layoutSubviews];
[self applyEditingModeBackgroundViewPositionCorrections];
}
/**
When using a backgroundView or selectedBackgroundView on a custom UITableViewCell
subclass, iOS7 currently
has a bug where tapping the Delete access control reveals the Delete button, only to have
the background cover it up again! Radar 14940393 has been filed for this. Until solved,
use this method in your Table Cell's layoutSubviews
to correct the behavior.
This solution courtesy of cyphers72 on the Apple Developer Forum, who posted the
working solution here: https://devforums.apple.com/message/873484#873484
*/
- (void)applyEditingModeBackgroundViewPositionCorrections {
if (!self.editing) { return; } // BAIL. This fix is not needed.
// Assertion: we are in editing mode.
// Do we have a regular background view?
if (self.backgroundView) {
// YES: So adjust the frame for that:
CGRect backgroundViewFrame = self.backgroundView.frame;
backgroundViewFrame.origin.x = 0;
self.backgroundView.frame = backgroundViewFrame;
}
// Do we have a selected background view?
if (self.selectedBackgroundView) {
// YES: So adjust the frame for that:
CGRect selectedBackgroundViewFrame = self.selectedBackgroundView.frame;
selectedBackgroundViewFrame.origin.x = 0;
self.selectedBackgroundView.frame = selectedBackgroundViewFrame;
}
}
ここで基本的に行っているのは、これらの背景ビューが編集モードの場合、テーブル セルのレイアウト時にこれらの背景ビューの x 原点をゼロにリセットすることです。それらが間違って翻訳されている理由と、Apple が提供する「削除」ボタン ビューの上にある理由は、おそらく、Apple が修正に取り組んでいる既知の問題の一部です。