material-showcase-ios icon indicating copy to clipboard operation
material-showcase-ios copied to clipboard

Showcase showing misplaced from assigned target view?

Open Saravana181187 opened this issue 6 years ago • 13 comments

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 image-21

But showcase shows in away from target view, I have provide the screenshot for the issue. Second Screenshot image-1

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.

Saravana181187 avatar Jul 25 '18 13:07 Saravana181187

It seems like you get newInspectionBtn button reference when it is not laid down correctly.

quangctkm9207 avatar Jul 27 '18 04:07 quangctkm9207

Same problem. Any solution /?

erfanwakka avatar Jan 09 '19 06:01 erfanwakka

Same problem. Any solution /?

Give us an example project to find the solution. For some reason, your control is not laid down correctly.

Husseinhj avatar Jan 09 '19 06:01 Husseinhj

` 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 avatar Jan 09 '19 07:01 erfanwakka

@erfanwakka Please put your code in ``` block code

```swift YOUR_CODE ```

Husseinhj avatar Jan 09 '19 07:01 Husseinhj

I did, It's just an BarButtonItem

erfanwakka avatar Jan 09 '19 07:01 erfanwakka

Are sure before calling viewDidAppear your bar button is laid down correctly?

What exactly does customNavigationItem do on BarButtonItem?

Husseinhj avatar Jan 09 '19 07:01 Husseinhj

I just change the title of my navigation bar button item

erfanwakka avatar Jan 09 '19 07:01 erfanwakka

Are sure before calling viewDidAppear your bar button is laid down correctly?

Are sure about this?

Husseinhj avatar Jan 09 '19 07:01 Husseinhj

could you specify laid down means ? In documents said just put it in ViewDidAppear and I do nothing after that

erfanwakka avatar Jan 09 '19 07:01 erfanwakka

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?

Husseinhj avatar Jan 09 '19 08:01 Husseinhj

@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.

Husseinhj avatar Jan 09 '19 08:01 Husseinhj

It seems that the view is not initialized from storyboard? So, it is not placed correctly before viewDidAppear() called.

quangctkm9207 avatar Jan 10 '19 00:01 quangctkm9207