Coder Social home page Coder Social logo

bwwalkthrough's Introduction


CocoaPods Carthage Compatible Platform Twitter

What is BWWalkthrough?

BWWalkthrough (BWWT) is a class that helps you create Walkthroughs for your iOS Apps. It differs from other similar classes in that there is no rigid template; BWWT is just a layer placed over your controllers that gives you complete freedom on the design of your views..

Preview

Video preview Here A dedicated tutorial is available on ThinkAndBuild

The class comes with a set of pre-built animations that are automatically applied to the subviews of each page. This set can be easily substituted with your custom animations.

BWWT is essentially defined by 2 classes: BWWalkthroughViewController is the Master (or Container). It shows the walkthrough and contains UI elements that are shared among all the Pages (like UIButtons and UIPageControl).

BWWalkthroughPageViewController defines every single Page that is going to be displayed with the walkthrough inside the Master.

What it's not?

BWWT is not a copy-paste-and-it-just-works class and it is not a fixed walkthrough template. If you need a simple no-configuration walkthrough, BWWT is not the right choice.

Installation

Note: There is a known issue with IBOutlets and Carthage that prevents Outlets from working correctly. I see something similar reported for other projects too. My suggestion is to follow the manual installation instructions, as it is just matter of drag and drop 2 files in your project. I know you cannot update the library automatically going that route... but IBOutlets are needed for a project like BWWalkthrough.

With CocoaPods

BWWalkthrough is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "BWWalkthrough"

With Carthage

Include this line into your Cartfile:

github "ariok/BWWalkthrough"

Run carthage update to build the framework and drag the built BWWalkthrough.framework into your Xcode project.

With Swift Package Manager

// swift-tools-version:5.0	
import PackageDescription
	
let package = Package(
name: "YourTestProject",
platforms: [
    .iOS(.v10),
],
dependencies: [
    .package(url: "https://github.com/ariok/BWWalkthrough/.git", from: "4.0.1")
],
targets: [
    .target(name: "YourTestProject", dependencies: ["BWWalkthrough"])
]
)

And then import wherever needed: import BWWalkthrough

Adding it to an existent iOS Project via Swift Package Manager

  1. Using Xcode 11 go to File > Swift Packages > Add Package Dependency
  2. Paste the project URL: https://github.com/ariok/BWWalkthrough
  3. Click on next and select the project target

If you have doubts, please, check the following links:

How to use

Creating Swift Packages

After successfully retrieved the package and added it to your project, just import BWWalkthrough and you can get the full benefits of it.

Manually

Include the BWWalkthrough/BWWalkthroughViewController.swift and the BWWalkthrough/BWWalkthroughPageViewController.swift files into your project.

How to use it?

Define the Master

Add a new controller to the Storyboard and set its class as BWWalkthroughViewController. This is the Master controller where every page will be attached.

Here you can add all the elements that have to be visible in all the Pages.

There are 4 prebuilt IBOutlets that you can attach to your elements to obtain some standard behaviours: UIPageControl (pageControl), UIButton to close/skip the walkthrough (closeButton) and UIButtons to navigate to the next and the previous page (nextButton, prevButton). You can take advantage of these IBOutlets just creating your UI elements and connecting them with the outlets of the Master controller.

Define the Pages

Add a new controller to the Storyboard and set it has BWWalkthroughPageViewController. Define your views as you prefer.

Attach Pages to the Master

Here is an example that shows how to create a walkthrough reading data from a dedicated Storyboard:

// Get view controllers and build the walkthrough
let stb = UIStoryboard(name: "Walkthrough", bundle: nil)
let walkthrough = stb.instantiateViewControllerWithIdentifier(“Master”) as BWWalkthroughViewController
let page_one = stb.instantiateViewControllerWithIdentifier(“page1) as UIViewController
let page_two = stb.instantiateViewControllerWithIdentifier(“page2) as UIViewController
let page_three = stb.instantiateViewControllerWithIdentifier(“page3) as UIViewController

// Attach the pages to the master
walkthrough.delegate = self
walkthrough.add(viewController:page_one)
walkthrough.add(viewController:page_two)
walkthrough.add(viewController:page_three)

Prebuilt Animations

You can add animations without writing a line of code. You just implement a new Page with its subviews and set an animation style using the runtime argument {Key: animationType, type: String} via IB. The BWWalkthrough animates your views depending on the selected animation style.

At the moment (WIP!) the possible value for animationsType are: Linear, Curve, Zoom and InOut The speed of the animation on the X and Y axes must be modified using the runtime argument {key: speed type:CGPoint}, while the runtime argument {key: speedVariance type: CGPoint} adds a speed variation to the the subviews of the page depending on the hierarchy position.

Example Let’s say that we have defined these runtime arguments for one of the Pages:

  • animationType: "Linear"
  • speed: {0,1}
  • speedVariance: {0,2}

The subviews of the Page will perform a linear animation adding speed to the upfront elements depending on speedVariance. So if we have 3 subviews, the speed of each view will be:

  • view 0 {0,1+2}
  • view 1 {0,1+2+2}
  • view 2 {0,1+2+2+2}

creating the infamous parallax effect.

Exclude Views from automatic animations

You might need to avoid animations for some specific subviews.To stop those views to be part of the automatic BWWalkthrough animations you can just specify a list of views’ tags that you don’t want to animate. The Inspectable property staticTags (available from version ~> 0.6) accepts a String where you can list these tags separated by comma (“1,3,9”). The views indicated by those tags are now excluded from the automatic animations.

Custom Animations

Each page of the walkthrough receives information about its normalized offset position implementing the protocol BWWalkthroughPage, so you can extend the prebuilt animations adding your super-custom-shiny-woah™ animations depending on this value (here is a simple example)

func walkthroughDidScroll(position: CGFloat, offset: CGFloat) {
    var tr = CATransform3DIdentity
    tr.m34 = -1/500.0
    titleLabel?.layer.transform = CATransform3DRotate(tr, CGFloat(M_PI)*2 * (1.0 - offset), 1, 1, 1)
}

Delegate

The BWWalkthroughViewControllerDelegate protocol defines some useful methods that you can implement to get more control over the Walkthrough flow.

@objc protocol BWWalkthroughViewControllerDelegate {
        @objc optional func walkthroughCloseButtonPressed()
        @objc optional func walkthroughNextButtonPressed()
        @objc optional func walkthroughPrevButtonPressed()
        @objc optional func walkthroughPageDidChange(pageNumber:Int)
}

bwwalkthrough's People

Contributors

apiejh avatar ariok avatar colemancda avatar gabrielpeart avatar kumapo avatar tomthorpe avatar willeeklund avatar wircho avatar yoichitgy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bwwalkthrough's Issues

Last page sometimes doesn't bounce back to its position

In the example app, I can swipe to the last page that says "Choose the style of every single page...". If I continue to swipe past the last page, it will briefly expose a blue background and then the page moves back to its offset of scrollview.contentOffset.x == 960.0. Occasionally though, the last page does not return to the 960 offset, but instead settles on 968.0 (revealing a thin blue stripe along the right edge).

Constraint issue in Xcode 8 Beta 6

.../Pods/BWWalkthrough/Pod/Classes/BWWalkthroughViewController.swift:236:53: Cannot assign value of type '[NSLayoutConstraint]' to type 'NSArray?'

// EDIT //

Fixed by changing
private var lastViewConstraint:NSArray?
To:
private var lastViewConstraint:[NSLayoutConstraint]?

Memory problem with larger number of views

I have used the BBWalkthrough to make an app but have more than 15 views it scrolls through. As the views that are not removed when they are not shown the memory is over 100mb used. Can you purge the views that are shown or being animated (views -1 and +1). Great work by the way!

Lock scrolling

Is there any way to lock scrolling and enable only the use of buttons to go to the different views?

Problem after walkthrough

Hello guys, is an incredible work that you have done. But I have a problem, when you finish the walkthrough I need to bring up the login screen and signup, but i don't know how to do it .. Any help?

thank you

Carthage support

Hi there,
is there any plans for carthage support in the future?

Thank you!

License?

I didn't see a license specified in the README. What License is this? I don't want to assume "Free as in beer when not specified" and I'm sure I'm not alone. :)

Nifty walkthrough, I'm gonna check it out...

Swift 3 Error:

I have this error in my code and also in the example app. I have used the code migrator to update the project to Swift 3 (the example).

2016-09-01 13:42:36.133 BWWalkthrough_Example[643:9268270] -[_SwiftValue nsli_superitem]: unrecognized selector sent to instance 0x60000005cfe0
2016-09-01 13:42:36.140 BWWalkthrough_Example[643:9268270] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue nsli_superitem]: unrecognized selector sent to instance 0x60000005cfe0'

It comes up with a sigabbt error on launch.

error swift 3

I am receiving this error in swift 3

for(i in 0 ..< subsWeights.count ){

expected ',' separator

this is in BWWalkthroughPageViewController.swift

Question:

First, congrats for the project !
Second: why the project is using class prefix if it is in Swift ?

Thanks.

Others effects

First at all, thanks for this amazing on boarding views, keep the nice work.

It is posible to stop the scroll or slider pass the views , I want to disable the slider for the left in the first view and the right on the last view (cause the images on those view looks bad in contrast of the color in background). Im was searching but with not luck by now.

And if its posible to add animation to each element of those views, like one for the image or title , like a fade animation. I know how to do the animation but I cant find where to implement it. Im new on swift and Im kind of confuse with the controller for all the views.

Thanks in advance.

delegate methods not working , Newbie question?

I'm trying to animate a object(uibutton) to animate when a certain BWWalkthroughPageViewController(changing pages) view controller appears on screen . using I used delegate method : func walkthroughPageDidChange(pageNumber:Int), however nothing is happening. I was told to set the delegate to self in view did load method but not sure how to do that. Any suggestions?

preferredStatusBarStyle not triggered

I need to change the status bar color. I set View controller-based status bar appearance to YES cause I need to hide status bar on specific viewcontroller. Overriding preferredStatusBarStyle on class extending your library will not triggered.

Only show close button on last page

Not an issue really, just a desired scenario. Can I only show the close button on the last walkthrough page? Thanks so much for awesome repo!

Rotation support

Control layout is broken after rotation if enable landscape mode. Any suggestions how to fix?

Adding Cocoapods support

I've forked your repository and will be adding Cocoapods support (Including update to README.MD)

how to programmatically close the walkthrough?

I am trying to close the walkthrough programmatically after user logs in. I implemented delegate in my class like so:

var walkthroughDelegate: BWWalkthroughViewControllerDelegate?

and called the close button like so:

self.walkthroughDelegate?.walkthroughCloseButtonPressed!()

But the walkthrough is not closing. There is no error either.

NSLayoutContraint crash in BWWalkthroughViewController

Xcode 8 with Swift 3.0

On line 229,
scrollview.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[previousView]-0-[view]", options:[], metrics: nil, views: ["previousView":previousView,"view":vc.view]))

throws

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue nsli_superitem]: unrecognized selector sent to instance 0x60000024d7a0

I apologize that I'm not too familiar with creating constraints in code, therefore can't offer anything more than pointing it out.

How to set the view's tags that I want to exclude the automatic animations

I'm a very beginner :(
This project is great !
I can attach the pages to the master with automatic animations
But I don't know how to exclude some views from the animation
What' the staticTags ? Should I create a runtime arguments with the key-path of staticTags?
And how to set the tags to the views I don't need animations?

THX :)

Use of undeclared type 'BWWalkthroughViewController'

When I add the code to manage subview I get error at

let walkthrough = stb.instantiateViewControllerWithIdentifier("master") as BWWalkthroughViewController

telling "Use of undeclared type 'BWWalkthroughViewController'"

I installed via pod install and xcode 7.2.1

addViewController flow issue

addViewController operate only with controllers view.
Should it also use addChildViewController and didMoveToParentViewController to correctly host controllers as child?

Cannot detect swipe

Hi, I want to detect swipe so i can restrict some views, for example i have 10 pages and i dont want swipe to work on number 4 page (on page 4 I only want to use button for swipe for swipe gesture)

Moving views

For whatever reason, the scroll view is allowing my pages to move in any direction. I've tried setting alwaysBounceVertical to false, and I've tried to remove all bounce from the scrollview to no avail.

Any ideas?

EDIT FWIW, my master is presented within a navigation controller. Although the navigation bar should show up, it's not. It seems like the tolerance for the "bounce" is about the same height as a navigation bar.

Background fade

Wanted to start off by saying, WOW! This is a great repo. Absolutely love it!

Anyways, I'm having problems trying to get the background color to fade.

I tried changing it under the walkthroughDidScroll function, but couldn't get it to work.

Any ideas?

Objective C

How can I use this library in Objective-C project, although this library is written in Swift?

Could not cast value of type 'BWWalkthrough.BWWalkthroughViewController' BWWalkthroughViewController'

So I have followed your tutorial step by step. Still having issues...

I have installed it first with CocoaPods and seems that others are having the same issue.

If I name the custom class module (top right on the identity inspector) BWWalkthrough it will crash with the following:
Could not cast value of type 'BWWalkthrough.BWWalkthroughViewController' (0x1054e6b50) to 'NameOfMyProject.BWWalkthroughViewController'

If I change the custom class module to NameOfMyProject (or leave it blank) it does not crash and the initial View Controller loads fine, when I tap the first button it simply does not load step0, the code executes fine, but nothing happens and I never get to see the first BWWalkthroughViewController.

I have tried with both cocoaPods and by copying the files. Spent a good two hours looking at this and got nowhere. Please help!!!!!

bwwalkviewcontroller page will backward to its parent issue

Hi Ariok,
I am a leaner of Swift and I am currently using bwwalkthrough. It works properly instead when the bwwalkthroughviewcontroller page(the main page) loads, if I tap on the upper half of the view, it will accidentally backward segue to its previous page and never shows again.

Here provides the repo url: [email protected]:evtechnologies/Wave.git

Thanks for help.

Loui

Infinite scrolling not supported

Is there a way to make it scroll infinitely? Like when the user reaches the last page, the walkthrough will go back to first page on the next swipe.

go to another view

Hello

I am trying to go to " another view control in main storyboard " by a button in one of the subviews

this what I did :

import UIKit
class GamesViewController: UIViewController {

    @IBAction func goToPlayView(sender: UIButton)

   {        
        let mainStb = UIStoryboard(name: "Main", bundle: nil)
        let play = mainStb.instantiateViewControllerWithIdentifier("Play") as! PlayViewController  
        self.presentViewController(play, animated: true, completion: nil);
    }
}

and I got this warring :
Presenting view controllers on detached view controllers is discouraged

please help

Update for Swift 2 Please!

@IBInspectable var staticTags:String {  
        set(value){
            self.notAnimatableViews = value.characters.split{$0 == ","}.map { String($0) }.map{Int(String($0))!}
        }
        get{
            return ",".join(notAnimatableViews.map{String($0)})
        }
    }

Error: 'join' has been explicitly marked unavailable here
Error: 'join' is unavailable: call the 'joinWithSeparator()' method on the sequence of elements

Could not cast to BWWalkthroughViewController

Could not cast value of type 'UIViewController' (0x1094ff5e0) to 'BWWalkthrough.BWWalkthroughViewController' (0x10734ab50).

I have made sure I imported BWWalkthrough and declared the delegate. But I keep getting this error on line:

walkthrough = stb.instantiateViewControllerWithIdentifier("container") as! BWWalkthroughViewController

I have ensured that the it is in fact a BWWalkthroughViewController in interface as well.

EDIT:
I have noticed that this error is thrown when I use CocoaPods to install BWWalkthrough - not when I include the files manually....

Problems with orientation and modally presented views

First of all, thanks for your great work!
I have an issue when it comes to displaying BWWalkthroughViewController on the iPad. When in landscape the constraints are all wrong and I have not found a solution for it. It is also displayed wrong if the BWWalkthroughViewController is presented as PageSheet or FormSheet. Any ideas?
Regards, Erik

Navigationbar issue

When embedding the Master View Controller into a navigation bar, and change the way it's a presented to be a push, the scrollview becomes unstable, it's scrolling all over different undefined spaces

Playing Video

Hi,

first off, fantastic work, this works absolutely brilliantly.

However i have one small issue, i would like to play a video file from one of the walkthrough pages. I created a custom UIViewController and implemented BWWalkthroughPage.

The video plays fine, however i get an error message in debug:
Presenting view controllers on detached view controllers is discouraged

The walkthrough then returns to the first page and freezes, I'm more than likely doing something stupid.

import UIKit
import MediaPlayer

class ServiceDemoViewController: UIViewController,BWWalkthroughPage {

    var moviePlayer: MPMoviePlayerViewController!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func playVideo(sender: AnyObject) {

        let path = NSBundle.mainBundle().pathForResource("ServicesOnly", ofType:"m4v")
        let url = NSURL.fileURLWithPath(path!)

        let videoURL = url
        moviePlayer = MPMoviePlayerViewController(contentURL: videoURL )

        if let player = moviePlayer {
            player.view.frame = self.view.bounds
            self.presentViewController(moviePlayer!, animated: true, completion: nil)
        }
        else {
            NSLog("no player")
        }
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: BWWalkThroughPage protocol
    func walkthroughDidScroll(position: CGFloat, offset: CGFloat) {
    }

}

Problem After Walkthrough

Hello, I have a problem with leaving the walkthrough to get to my login page. How do you connect to login view controller out of walkthrough? Any help please.

ScrollView not scrolling with next/prev buttons, even though nextPage() is getting called.

I have configured BWWalkthough using storyboard, as the example project does. Everything works great. But I can't seem to get the nextButton/prevButton to work. The IBOutlets are connect properly and the nextPage() action is called. The delegate even receives walkthroughNextButtonPressed/walkthroughPrevButtonPressed calls. The actual scrolling never occurs though. Any thoughts?

I am using a subclass of BWWalkthroughViewController as follows:
class WelcomeWalkthroughViewController: BWWalkthroughViewController, BWWalkthroughViewControllerDelegate { ... }

launch navigation controller from a page

I have a strange problem, i added a button in a page of slider, with this action:

let blckView = stb.instantiateViewControllerWithIdentifier("blc") as! BlockedContactTableViewController
        blckView.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack")
        let navController = UINavigationController(rootViewController: blckView) // Creating a navigation controller with resultController at the root of the navigation stack.
        self.presentViewController(navController, animated: true, completion: nil)

The navigation has been displayed, but the page BWWalkthroughPageViewController has been resized wrong, and when i close the new navigation i'm not able to scroll but i can only click close button, any idea?

Problem with 'override init()' function

Hi there,

On Xcode 6.3 there seems to be a bunch of issues, most of which are fixable with the self-help fixit suggestions, but the one which isn't so obvious is the following method..

override init() {
super.init()
scrollview = UIScrollView()
controllers = Array()

}

which throws the error -> 'Initializer does not override a designated initializer from its superclass'

Not sure how to effectively resolve. Any suggestions? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.