私は、テーブルセル内のコンテナビューに埋め込まれたボタンとラベルで同様の問題が発生しました。タッチイベントはボタンによって傍受されていました。
あなたがプレスにハイライトするボタンを必要としない場合は、私がやったことは、タップジェスチャー認識代わりのボタンでのUIViewを使用することでした。
let fakeButtonView = UIView()
fakeButtonView.translatesAutoresizingMaskIntoConstraints = false
fakeButtonView.backgroundColor = UIColor.whiteColor()
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(buttonTapped))
fakeButtonView.addGestureRecognizer(gestureRecognizer)
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = ...
label.numberOfLines = 1
label.textAlignment = .Center
label.lineBreakMode = .ByTruncatingTail
label.minimumScaleFactor = 0.5
label.font = UIFont.systemFontOfSize(17.0)
fakeButtonView.addSubview(label)
fakeButtonView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-5-[label]-5-|",
options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["label": label]))
fakeButtonView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[label]|",
options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["label": label]))
container.addSubview(fakeButtonView)
// Constraints from button to container
//
// ...
おかげで、私はこれを使用して終わる可能性がありますが、私はどのように把握しようとしていますtouchesShouldCancelInContentViewを具体的に実装します。私はそれが他のものと一緒に私を助けるかもしれないと思う。 – Justin
あなたがまだ興味があるならば、ちょうど私が投稿した答えを見てください - 私は落とした単純な方法でこれを行う方法を考え出しました。ウェイが少なくて済み、まだボタンの状態を使用するようになります – Justin
ありがとう、私はチャンスがあるときにそれを試してみましょう。ボタンの状態は間違いなくボーナスです! – Yasir