material-showcase-ios
material-showcase-ios copied to clipboard
Showcase showing misplaced from assigned target view?
I want to display showcase for button so I code for that but it shows in misplaced from assigned target view.
I have set the target view for '+' symbol button in the following screen shot.
First Screenshot
But showcase shows in away from target view, I have provide the screenshot for the issue.
Second Screenshot
And Here I provide the code what I am tried. `override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) showButtonShowcase(newInspectionBtn) }
//MARK: - display showcase
func showButtonShowcase(_ sender: UIButton) {
let showcase = MaterialShowcase()
showcase.setTargetView(view: sender)
showcase.backgroundViewType = .circle
showcase.targetTintColor = UIColor.clear
showcase.targetHolderColor = UIColor.clear
showcase.primaryText = "Add Inspection"
showcase.secondaryText = "Click here to go into details"
showcase.shouldSetTintColor = false // It should be set to false when button uses image.
showcase.isTapRecognizerForTagretView = true
showcase.show(completion: {
print("==== completion Action 1.1 ====")
// You can save showcase state here
})
}`
Please help and find me what wrong I do this code and how to fix the issue.
It seems like you get newInspectionBtn
button reference when it is not laid down correctly.
Same problem. Any solution /?
Same problem. Any solution /?
Give us an example project to find the solution. For some reason, your control is not laid down correctly.
` class WalletVC: BaseVC {
@IBOutlet weak var leftNavigationItem: UIBarButtonIte
fileprivate let walletViewModel = WalletViewModel()
var showCaseState = 0
var pageMenu: CAPSPageMenu?
var controllerArray: [UIViewController] = []
lazy var showBalanceUseCase: MaterialShowcase = {
let showcase = MaterialShowcase()
showcase.setTargetView(barButtonItem: leftNavigationItem)
showcase.primaryText = "مقدار موجودی شما"
showcase.secondaryText = ""
showcase.targetHolderColor = .clear
showcase.primaryTextFont = R.font.iranSansMobile(size: 15)
showcase.primaryTextAlignment = .right
return showcase
}()
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(updateBalance), name:NSNotification.Name(rawValue: "update-balance"), object: nil)
initUI()
setupPageMenu()
updateBalance()
handleCustomNotification()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
showBalanceUseCase.show {}
}}
func initUI() {
rightNavigationTitle(title: "اعتبار من")
customNavigationItem(barButtonItem: leftNavigationItem)
}
func handleCustomNotification() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) {(_,_) in}
UIApplication.shared.registerForRemoteNotifications()
}
}`
@erfanwakka Please put your code in ``` block code
```swift YOUR_CODE ```
I did, It's just an BarButtonItem
Are sure before calling viewDidAppear
your bar button is laid down correctly?
What exactly does customNavigationItem
do on BarButtonItem?
I just change the title of my navigation bar button item
Are sure before calling
viewDidAppear
your bar button is laid down correctly?
Are sure about this?
could you specify laid down means ? In documents said just put it in ViewDidAppear and I do nothing after that
could you specify laid down means? In documents said just put it in ViewDidAppear and I do nothing after that
Means are you sure your BarButton before calling viewDidAppear
or calling showBalanceUseCase.show {}
has been loaded or appeared?
@erfanwakka I think the simple way to find out the problem, Create a clean project with the exact scenario (Copy your codes in your sample project) and share the repository with us to debug your code.
It seems that the view is not initialized from storyboard? So, it is not placed correctly before viewDidAppear() called.