ealeksandrov / EAIntroView

Highly customizable drop-in solution for introduction views.
MIT License
3.76k stars 501 forks source link

Issues preventing scroll from going past last view #152

Closed tunds closed 8 years ago

tunds commented 8 years ago

I'm having issues preventing the view from scrolling past the last view, if the user scrolls pasts the last view they're presented with the original viewcontroller that it's attached too.

Here's is the code that i'm using to prevent this from happening.

    func setUpIAPOptions(){

        let welcomePage = EAIntroPage(customViewFromNibNamed: "welcomeIAPView")
        let firstIAPPage = EAIntroPage(customViewFromNibNamed: "firstIAPView")
        let secondIAPPage = EAIntroPage(customViewFromNibNamed: "secondIAPView")
        let thirdIAPPage = EAIntroPage(customViewFromNibNamed: "thirdIAPView")

        // CREATE BUTTON ACTIONS
        let options = EAIntroView(frame: self.view.bounds, andPages: [welcomePage,firstIAPPage,secondIAPPage,thirdIAPPage])

        options.addSubview(createDismissButton(self.view))

        options.skipButton.enabled = false
        options.skipButton.alpha = 0

        // Here i'm trying to prevent the scroll from going past the last page, the 4th one  
        options.limitScrollingToPage(3)

        options.delegate = self

        let firstIAPBtn = firstIAPPage.pageView.viewWithTag(1) as! SpringButton
        firstIAPBtn.addTarget(self, action: "firstIAPSelected:", forControlEvents: .TouchUpInside)

        let secondIAPBtn = secondIAPPage.pageView.viewWithTag(1) as! SpringButton
        secondIAPBtn.addTarget(self, action: "secondIAPSelected:", forControlEvents: .TouchUpInside)

        let thirdIAPBtn = thirdIAPPage.pageView.viewWithTag(1) as! SpringButton
        thirdIAPBtn.addTarget(self, action: "thirdIAPSelected:", forControlEvents: .TouchUpInside)

        options.showInView(self.view)

    }

Screenshots attached.

img_5577 img_5578

Moyasengit commented 8 years ago

Hmm.. if you look in the file EAIntroView.m you search for"swipeToExit". I think in line 61 there is "self.swipeToExit = YES;" This is the method that makes that call for the last VC.

You can call that method in the class like so: intro.swipeToExit = NO;

And it should be done =) Sincerely

tunds commented 8 years ago

Is there a way to access this property from my VC? Since i'm using cocoapods and if this repo gets updated it will revert it back to it's previous value.

Moyasengit commented 8 years ago

hmm... cal it from your VC where you have your code already. the instance of theEAIntroView. Try type

options.swipeToExit = NO;

tunds commented 8 years ago

Sweet that worked thanks for that :D

Moyasengit commented 8 years ago

Great, nice that it worked! You're welcome!