aromajoin / material-showcase-ios

✨ An elegant way to guide your beloved users in iOS apps - Material Showcase.
https://aromajoin.com/
Other
363 stars 128 forks source link

MaterialShowcase/MaterialShowcase.swift:371: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value #161

Open HarshParekh03 opened 9 months ago

HarshParekh03 commented 9 months ago

I have provided below code where is face crash in containerView function of initViews() and below is how i use in viewDidLoad() and viewWillAppear i also tried setting up in viewdidAppear but still facing the crash. Please help me with a solution as i have already implemented in client project.

let showcase = MaterialShowcase()

self.showcase.setTargetView(button: self.btnLogin)

override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.showcase.show { print("Success") } }

func initViews() { let center = calculateCenter(at: targetView, to: containerView)

addTargetRipple(at: center)
addTargetHolder(at: center)

// if color is not UIColor.clear, then add the target snapshot
if targetHolderColor != .clear {
  addTarget(at: center)
}

addBackground()

addInstructionView(at: center)
instructionView.layoutIfNeeded()

// Disable subview interaction to let users click to general view only
subviews.forEach({$0.isUserInteractionEnabled = false})

if isTapRecognizerForTargetView {
  //Add gesture recognizer for targetCopyView
  hiddenTargetHolderView.addGestureRecognizer(tapGestureRecoganizer())
  hiddenTargetHolderView.isUserInteractionEnabled = true
} else {
  // Add gesture recognizer for both container and its subview
  addGestureRecognizer(tapGestureRecoganizer())
  hiddenTargetHolderView.addGestureRecognizer(tapGestureRecoganizer())
  hiddenTargetHolderView.isUserInteractionEnabled = true
}

}