diff --git a/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift b/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift index cd99a543..2125ae9a 100644 --- a/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift +++ b/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift @@ -327,6 +327,12 @@ class FeedSocialWorkCell: FeedBasicCell { }) } } + + voiceContainerView.playOrPauseAudioAction = { [weak self] in + if let strongSelf = self { + strongSelf.playOrPauseAudioAction?(strongSelf) + } + } } } } @@ -387,11 +393,6 @@ class FeedSocialWorkCell: FeedBasicCell { // MARK: Actions - @IBAction func playOrPauseAudio(sender: UIButton) { - - playOrPauseAudioAction?(self) - } - func tapDribbbleMedia(sender: UITapGestureRecognizer) { guard let feed = feed, attachment = feed.attachment else { diff --git a/Yep/Views/ContainerViews/FeedVoiceContainerView.swift b/Yep/Views/ContainerViews/FeedVoiceContainerView.swift index c525805b..212b78d4 100644 --- a/Yep/Views/ContainerViews/FeedVoiceContainerView.swift +++ b/Yep/Views/ContainerViews/FeedVoiceContainerView.swift @@ -10,6 +10,8 @@ import UIKit class FeedVoiceContainerView: UIView { + var playOrPauseAudioAction: (() -> Void)? + var audioPlaying: Bool = false { willSet { if newValue != audioPlaying { @@ -34,6 +36,8 @@ class FeedVoiceContainerView: UIView { button.setImage(UIImage(named: "icon_play"), forState: .Normal) button.tintColor = UIColor.lightGrayColor() button.tintAdjustmentMode = .Normal + + button.addTarget(self, action: "playOrPauseAudio:", forControlEvents: .TouchUpInside) return button }() @@ -95,5 +99,9 @@ class FeedVoiceContainerView: UIView { NSLayoutConstraint.activateConstraints([playButtonCenterY]) } + + @objc private func playOrPauseAudio(sender: UIButton) { + playOrPauseAudioAction?() + } }