Coder Social home page Coder Social logo

mxscroll's Introduction

banner

MXScroll

Version License Platform

MXScroll is a framework that lets you create mix scroll view easier. you can just provide the datasource and do not need to consider the page composition. the datasource can be provided by storyboard or programmatically.

Structure

structure

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

WKWebView UIScrollView UIView
wkwebview UIScrollView UIView

Requirements

  • Xcode 9+
  • Swift 4.0+
  • iOS 10.0+

Installation

Swift compatibility

To work with Swift 4.0 use MXScroll v.0.1.0.

To work with Swift 4.1 use MXScroll v.0.1.2.

To work with Swift 5.0 use MXScroll v.0.1.3

Cocoapods

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

pod 'MXScroll'

Usage

Simple

1. First you should
import MXScroll
2. Prepare Header
let header = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "HeaderViewController")

if WKWebView , UIWebView or UIScrollView is in HeaderVC, you should implement MXViewControllerViewSource.

extension HeaderViewController:MXViewControllerViewSource{
      func headerViewForContentOb() -> UIView? {
          return webView
      }
}
3. Prepare Content
let child1 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ChildViewController")

if UITableView or UIScrollView is in ContentVC, you should implement MXViewControllerViewSource

extension ChildViewController:MXViewControllerViewSource{
       func viewForMixToObserveContentOffsetChange() -> UIView {
           return self.tableView
       }
}
4. Prepare Segment

You can use the MSSegmentControl provide by MXScroll

  let segment = MSSegmentControl(sectionTitles: ["1", "2"])
5. Mix
let header = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "HeaderViewController")
        
let child1 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ChildViewController")
        
let child2 = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "SecondViewController")
        
let segment = MSSegmentControl(sectionTitles: ["1", "2"])
        
let mx = MXViewController<MSSegmentControl>.init(headerViewController: header, segmentControllers: [child1, child2], segmentView: segment)
navigationController?.pushViewController(mx, animated: true)

Segment

If you want to use the custom Segment,Just implementMXSegmentProtocol

extension MSSegmentControl: MXSegmentProtocol {
    // segment change to tell vc
    public var change: ((Int) -> Void) {
        get {
            return self._didIndexChange
        }
        set {
            self._didIndexChange = newValue
        }
    }
    
    // vc change callback method
    public func setSelected(index: Int, animator: Bool) {
        self.setSelected(forIndex: index, animated: animator, shouldNotify: true)
    }
}

Author

cillyfly, [email protected]

License

MXScroll is available under the MIT license. See the LICENSE file for more info.

mxscroll's People

Contributors

cillyfly 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

mxscroll's Issues

SegmentView with both icons and title and the selected option should be highlighted

I have integrated your library in to our project for the purpose of sticky header, we have achieved the same and glad to use your library, we have to show the title and icons in the segmented view, but the icons are half visible, I tried to enhance the segment view's height, but in vain, I request you to prepare an example for implementing the segmented view with both icons and title, provided the selected option should be highlighted.

or else, Kindly send an example how to use a custom segmented control.

Thanks & Regards
simulator screen shot - iphone xr - 2018-12-31 at 20 30 24

addSubView in MXViewController make contentScrollView Offset down 44

when I addSubView in MXViewController in viewDidLoad ,
the make contentScrollView Offset down 44
My Code is:

var navView = BaseNavView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: kNavH))

public override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(navView)
}

Segment view related issue

When I have used 2 segments at that time its works very good, but if when I have used 1 segment that time it's not working properly. Segment title was not shown when we only 1 segment added. For more understanding picture is attached below.

Segment shown Image:

Simulator Screen Shot - iPhone 8 - 2020-01-11 at 16 04 16

Coding Image:
Screenshot 2020-01-11 at 4 04 44 PM

Please give me a solution as soon as possible.

Having memory leakage.

I have integrated this SDK into my live project but due to memory leakages, my app is crashing. then I check this it also showed me leakages.
Screenshot 2023-04-19 at 9 42 02 AM

Redirect issue

I have 3 segments and all segments have personal controllers. when I open the screen, how to redirect directly on the third segment with the controller?

mx.segmentView.setSelected(index: 2, animator: true) - use of setSelected only chnage index of current segment indicator not controller.

Does anyone help?

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.