Coder Social home page Coder Social logo

scrollpager's Introduction

ScrollPager Version

A scroll pager similar to the one in Flipboard. The control creates a tabbar given a title or an image, and has the option of connecting to a UIScrollView to automatically present given views and manage paging between these views

alt tag

Usage:

Drag and drop a UIView into storyboard or xib.

OPTIONAL: If you like to use a scroll view assign the outlet to a scrollView.

Tab with text

scrollPager.addSegmentsWithTitles(["Home", "Public Feed", "Profile"])

Tab with images and views (will automatically add paging to scrollview and displays the views accordingly)

scrollPager.addSegmentsWithTitlesAndViews([
  ("Home", firstView),
  ("Public Feed", secondView),
  ("Profile", thirdView)
])

Tab with images

secondScrollPager.addSegmentsWithImages([
  UIImage(named: "envelope")!,
  UIImage(named: "home")!
])

Tab with images and views (will automatically add paging to scrollview and displays the views accordingly)

scrollPager.addSegmentsWithImagesAndViews([
  (UIImage(named: "envelope")!, firstView),
  (UIImage(named: "home")!, secondView),
  (UIImage(named: "anotherImage")!, thirdView)
])

scrollpager's People

Contributors

aryaxt avatar bryant1410 avatar lfarah avatar mateusznadolski avatar patricks 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

scrollpager's Issues

Horizontally scroll between segments ?

Hi,

I really love what you did so far with the ScrollPager, it's really well implemented & easy to understand.

One question though :

  • Is it possible to horizontally scroll between the segments if there is too many ?

Thanks.

Problem with orientation change

Hi, I have 4 views with Labels. When I change orientation the view is in wrong position (I think the scroll view is responsible for this).

This is how it looks

and from landscape to portrait

I have managed to do some nasty hack with this code

var lastIndex = 0

func scrollPager(scrollPager: ScrollPager, changedIndex: Int) {
    print("scrollPager index changed: \(changedIndex)")
    lastIndex = changedIndex
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
    coordinator.animate(alongsideTransition: nil) { _ in
            
        self.scrollPager.setSelectedIndex(index: self.lastIndex, animated: false)
    }
}

It would be much better when selectedIndex property was public (the getter) than private because I wouldn't have to remember the index. Please fix this to scroll automatically to right view when orientation changes.

menu have multi items

i have a menu with multi items , and it' scale to fit screen. with alot .(dot) .... i want it slide like other tabbar .

when i put scrollpage to a scrollview. it's work, but . the scroll not auto run to the item when i change the view.!

Crash while setting up without InterfaceBuilder

I am using ScrollPager in code and trying to set up with my viewControllers.
These controllers are using AutoLayout to setup constraints.

let library = ImagePickerController()

let photo = CameraViewController()

lazy var bottomScrollPager: ScrollPager = { [unowned self] in
  let scrollPager = ScrollPager()
  scrollPager.translatesAutoresizingMaskIntoConstraints = false
  scrollPager.addSegmentsWithTitlesAndViews([("LIBRARY", self.library.view),("PHOTO", self.photo.view),("VIDEO", UIView())])
  scrollPager.delegate = self
  return scrollPager
}()

But the views did not appear. Also application crashed:

fatal error: unexpectedly found nil while unwrapping an Optional value

Error shows on the for view in scrollView!.subviews line;

private func addViews(segmentViews: [UIView]) {
    for view in scrollView!.subviews {
        view.removeFromSuperview()
    }

    for i in 0..<segmentViews.count {
        let view = segmentViews[i]
        scrollView!.addSubview(view)
        views.append(view)
    }
}

I noticed that the scrollView is optional which marked with ? and when I am not in IB or xib.
I guess that the reason why the crash happened?

How to use multiple view controllers

Hello, how to show view controllers instead of UIView(UILabel) on each page?

I've searched on Google that I can used container view controllers. But I'm a bit stuck to combined it with this library?

can you give me some hints how to implement it? or maybe examples code.

Thank you very much and sorry for my bad English.

best regards,

Webview on each Page

Hi!

I want to add a webview on each page, but how do I do this?
So if you slide to the next page the next webview shows up.
Swift is pretty new for me so it would be great if you could help me out with this problem :)

Thanks!

addSegmentsWithTitlesAndViews doesn't appear in Objective-c Header file

When using the ScrollPager class in an Objective-C project, the below function:
public func addSegmentsWithTitlesAndViews(segments: [(title: String, view: UIView)])
doesn't appear in the header file created by xcode (addSegmentsWithTitles is included and works perfectly).

Any idea why? Or if there's a turnaround to adding different/same subview in all scroll indexes ?

Thank you

screen shot 2015-04-29 at 4 27 24 pm

Disable horizontal scrolling

Hey, is it possible to disable horizontal scrolling? I only want the buttons to change the views because my views are all table views and I want to enable actions on table cells.

build failed ):

build failed ):
swift method addSegments conflicts with OC selector,

Add ViewControllers to ScrollPager

How I can add a viewController to the ScrollPager? In my case i have a collectionView In a view controller and i want load like a view in the scrollPager. I do this, but it shows a with view.

let viewController = ViewController()
let fourthView = viewController.view
scrollPager.delegate = self
scrollPager.addSegmentsWithTitlesAndViews([
("Profile", thirdView),
("One More", fourthView)
])
scrollPager.delegate = self

Can u help me? I really need this scrollPager

Not possible to add a view controller's view?

Hi, how can I add a view that belongs to a view controller?
If I do that, when I interact with something it crashes without exception.
You know how to make some work around?
I really want to use this on my project.

Thanks

problem to change background color of scrollview

helllo

in have a problem with this awesome library man ...
my problem is when i use this library i cant change the background color of scrollview ... is this a issue or do you have any idea ????

sorry for my bad english and thank you :)

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.