I’ve a number of Faucet gestures I have to register in a UIView, specifically the segmentView
(that are working advantageous), the thumbnailButton
gesture recognizer and the muteButton
gesture recognizer. Nonetheless the faucet gesture on the thumbnailButton
and muteButton
views aren’t functioning for some purpose, the views from them are displaying accurately although. The TimelineView
UIView is generated on the viewDidLoad
operate within the father or mother UIViewController
I’m uncertain why that is occurring, any assistance is drastically appreaciated.
I’ve already tried, trying within the view hierarchy for any overlapping views, putting the gesture recognizer of their coresponding views themselves, and turning the views into UIButtons to see if that might repair one thing.
class TimelineView: UIView {
var segmentViewArray: [SAETimeLineRenderTrackSegmentView] = []
var transitionBlockArray: [SAETransitionBlockView] = []
var timelineButtonArray: [UIView] = []
weak var delegate: SAETimeLineRenderTrackViewDelegate?
init(delegate: SAETimeLineRenderTrackViewDelegate) {
self.delegate = delegate
tremendous.init(body: CGRect.zero)
self.backgroundColor = UIColor.clear
}
@objc func longGressGestureRecognizerAction(longGress: UILongPressGestureRecognizer) {
swap longGress.state {
case .started:
let selectedIndex = segmentViewArray.firstIndex(of: longGress.view! as! SAETimeLineRenderTrackSegmentView)
self.delegate?.showDragSortRenderTrackSegmentView(with: selectedIndex!)
self.delegate?.startDragSortRenderTrackSegmentView(with: longGress)
case .modified:
self.delegate?.continuedDragSortRenderTrackSegmentView(with: longGress)
case .ended:
self.delegate?.endDragSortRenderTrackSegmentView(with: longGress)
default:
print("default")
}
}
@objc func tapGestureRecognizerActionForTransition(tapGetsure: UITapGestureRecognizer){
print("--- Timeline Render Monitor View: Transition click on registered ---")
guard let transitionBlock = tapGetsure.view as? SAETransitionBlockView else { return }
self.delegate?.addTransitionBetweenSegmentViews(with: transitionBlock)
}
@objc func tapGestureRecognizerAction(tapGesture: UITapGestureRecognizer) {
NotificationCenter.default.submit(identify: Notification.Identify.init(rawValue: SAEConstants.VLETimeLineShowSecondLevelEffectsViewNotification),object: nil)
let view = tapGesture.view as! SAETimeLineRenderTrackSegmentView
let index = segmentViewArray.firstIndex(of: view)
self.delegate?.showRenderTrackDragView(with: view, index: index!)
}
@objc func tapGestureRecognizerActionForMute(tapGetsure: UITapGestureRecognizer){
// self.delegate?.mutePlayerAudio(isMute: true)
print("Mute tapped")
}
@objc func tapGestureRecognizerActionForThumbnail(tapGetsure: UITapGestureRecognizer){
// self.showHUD(progressLabel: "Thumbanil tapped", delay: 0.5)
print("Thumbnail tapped")
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been applied")
}
func removeAllSegmentView() {
for merchandise in segmentViewArray {
merchandise.removeFromSuperview()
}
segmentViewArray.removeAll()
}
func removeAllTransitionBlockView() {
for block in transitionBlockArray {
block.removeFromSuperview()
}
transitionBlockArray.removeAll()
}
func removeAllTimelineButtons(){
for merchandise in timelineButtonArray {
merchandise.removeFromSuperview()
}
timelineButtonArray.removeAll()
}
func refreshSegmentViewWith(itemModelArray: [SAETimeLineItemModel]) {
guard !itemModelArray.isEmpty else {
return
}
removeAllTransitionBlockView()
removeAllSegmentView()
removeAllTimelineButtons()
var second: CGFloat = 0
var width: CGFloat = 0
var frontSegmentView: SAETimeLineRenderTrackSegmentView?
let buttonStack = generateTimelineButtons()
buttonStack.snp.makeConstraints{ make in
make.peak.high.equalToSuperview()
make.proper.equalTo(self.snp.left).offset(-15)
make.width.equalTo(self.snp.peak).multipliedBy(2.2)
}
for merchandise in itemModelArray {
second = CGFloat(merchandise.supply.selectedTimeRange.period.worth)/CGFloat(merchandise.supply.selectedTimeRange.period.timescale)
width = SAETimeLineConfig.convertToPt(worth: Float(second))
let segmentView = generateSegmentView(with: merchandise)
if frontSegmentView == nil {
segmentView.snp.makeConstraints { make in
make.peak.high.left.equalToSuperview()
make.width.equalTo(width)
}
} else {
let transitionBlock = generateTransitionBlock(with: frontSegmentView!, and: segmentView)
transitionBlock.snp.makeConstraints { make in
make.width.peak.equalTo(20)
make.centerY.equalToSuperview()
make.left.equalTo(frontSegmentView!.snp.proper).offset(-10)
}
segmentView.snp.makeConstraints { make in
make.peak.high.equalToSuperview()
make.width.equalTo(width)
make.left.equalTo(frontSegmentView!.snp.proper)
}
}
var depend = Int(width/self.bounds.peak)
if width.truncatingRemainder(dividingBy: self.bounds.peak) > 0 {
depend += 1
}
merchandise.isSeparateRenderTrack = false
segmentView.refreshThumbnailImageView(depend: depend)
frontSegmentView = segmentView
}
}
func generateTimelineButtons() -> UIStackView {
let containverStack = UIStackView()
let thumbnailButton = SAETimelineThumbnailView.init()
let tap1 = UITapGestureRecognizer(goal: self, motion: #selector(tapGestureRecognizerActionForThumbnail(tapGetsure:)))
tap1.numberOfTapsRequired = 1
thumbnailButton.isUserInteractionEnabled = true
thumbnailButton.addGestureRecognizer(tap1)
let muteButton = SAETimelineMuteView.init()
let tap2 = UITapGestureRecognizer(goal: self, motion: #selector(tapGestureRecognizerActionForMute(tapGetsure:)))
muteButton.isUserInteractionEnabled = true
muteButton.addGestureRecognizer(tap2)
containverStack.distribution = .fillEqually
containverStack.addArrangedSubview(muteButton)
containverStack.addArrangedSubview(thumbnailButton)
timelineButtonArray.append(contentsOf: [thumbnailButton, muteButton])
self.addSubview(containverStack)
print("container view body is (containverStack.body)")
print("Container stack superview: (containverStack.superview)")
return containverStack
}
func generateTransitionBlock(with segment1: SAETimeLineRenderTrackSegmentView, and segment2: SAETimeLineRenderTrackSegmentView) -> SAETransitionBlockView {
let transitionModel = SAETimeLineTransitionModel(segment1: segment1.mannequin, segment2: segment2.mannequin)
let block = SAETransitionBlockView(mannequin: transitionModel)
let faucet = UITapGestureRecognizer(goal: self, motion: #selector(tapGestureRecognizerActionForTransition(tapGetsure:)))
block.addGestureRecognizer(faucet)
transitionBlockArray.append(block)
self.addSubview(block)
return block
}
func generateSegmentView(with itemModel: SAETimeLineItemModel) -> SAETimeLineRenderTrackSegmentView {
let segmentView = SAETimeLineRenderTrackSegmentView.init(with: itemModel)
let longGress = UILongPressGestureRecognizer.init()
longGress.addTarget(self, motion: #selector(longGressGestureRecognizerAction(longGress:)))
segmentView.addGestureRecognizer(longGress)
let tapGuesture = UITapGestureRecognizer.init()
tapGuesture.addTarget(self, motion: #selector(tapGestureRecognizerAction(tapGesture:)))
segmentView.addGestureRecognizer(tapGuesture)
segmentViewArray.append(segmentView)
self.addSubview(segmentView)
print("phase view body is (segmentView.body)")
return segmentView
}
}