teodorpatras / EasyTipView

Fully customisable tooltip view in Swift for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto dismiss (dispatch_after)

abousaif56 opened this issue · comments

I am a beginner in swift, I used the easytipview its is really good... I have installed the easytipview in my project and is working fine, no problems... I click on it and it goes away..
But also I need to dismiss it automatically (say after 5 seconds) as mentioned in the issue #48 (Auto dismiss option? #48) by rebenquito.. can anyone please explain into more details for me how to use the dispatch_after recommended by the owner as he didn't elaborate , I tried many ways but was unsuccessful.. I use swift 4, appreciate your help. thanks

Use a timer to do this.

private func setupTimer() {
        // Weak self, won't dismiss tool tip
        Timer.scheduledTimer(withTimeInterval: showForSeconds, repeats: false) { _ in
            self.easyTipView.dismiss()
        }
    }

Hello JackIrish, thanks for your help.. but unfortunately its not working , i get errors..
i removed the self. , still errors come up .. i don't understand the error , its not clear to me...please see image..
screen shot 2019-01-23 at 10 20 54 am

You can't use dismiss() on the class directly, it is an instance method, so declare an instance of EasyTipView, then you can call all show and dismiss methods that you need. e.g.
var toolTip = EasyTipView()
// Do your stuff with the tool tip
toolTip.dismiss()