• This repository has been archived on 25/Jun/2021
  • Stars
    star
    198
  • Rank 196,898 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Efficient Scrolling UIStackView in Swift - DEPRECATED (use ScrollStackController)

ScrollingStackContainer

Carthage compatible CI Status Version License Platform

★★ Star our github repository to help us! ★★

Created by Daniele Margutti (@danielemargutti)

⚠️ THE FOLLOWING LIBRARY WAS ARCHIVED. YOU CAN USE ScrollStackController

ScrollingStackContainer is an efficient scrolling UIStackView replacement, more suitable in situations when you are building a scrolling container with an heterogeneous number of items. It allows you to stack vertically UIViewController instances where the view is a simple fixed-height UIView or a UICollectionView or UITableView.

Motivation

A full article about the motivation behind this class is available on Medium (or in my personal blog). Check it here for full details about how the class works.

UITableView and UICollectionView are great when you need to display a number of relatively simple cells; when your layout became complex you may need to create different UIViewController which manages each different kind layout. These view controller may contains simple fixed-height UIView or complex UICollectionView/UITableView; in these cases you need to be careful because expading your scrollviews will destroy internal iOS caching mechanism. ScrollingStackContainer allows you to stack view controllers easily without any worry; it manages view controllers with scrolling collections automatically in order to reduce the amount of memory usage.

How to use it

It's very simple to implement: for fixed height views you should set a valid height (grater than zero). This can be done in your UIViewController's subclass in one of the following ways:

  • set an height constraint on UIViewController’s .view
  • … or return a value into preferredContentSize() function
  • … or set the height via self.frame
  • … or by implementing the StackContainable protocol and returning .view(height: <height>) with a valid value.

For view controllers which contains inner’s scroll views (for example table or collections) you need to implement the StackContainble protocol by returning .scroll(<inner scroll instance>, <insets of the inner scroll in superview>).

After that you should simply set the viewControllers property of your ScrollingStackContainer subclass:

	// view controller's view are stacked vertically in order
	self.viewControllers = [controller_2,controller_1,controller_3]

That’s all! All the business logic is managed by the class and you can enjoy!

See the example in this repository to get a live preview!

The following example is a vertical stack which contains a fixed height view controller, a view controller with a table inside and another fixed height controller.

ScrollingStackContainer

You also may like

Do you like ScrollingStackContainer? I'm also working on several other opensource libraries.

Take a look here:

  • Hydra - Promises & Await/Async in Swift - Write better async code in Swift
  • SwiftLocation - CoreLocation and Beacon Monitoring on steroid!
  • SwiftRichString - Elegant and painless attributed string in Swift
  • SwiftScanner - String scanner in pure Swift with full unicode support
  • SwiftSimplify - Tiny high-performance Swift Polyline Simplification Library
  • SwiftMsgPack - MsgPack Encoder/Decoder in Swit

Installation

ScrollingStackContainer supports multiple methods for installing the library in a project.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like ScrollingStackContainer in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate ScrollingStackContainer into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
use_frameworks!
pod 'ScrollingStackContainer', '~> 0.5'
end

Then, run the following command:

$ pod install

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate ScrollingStackContainer into your Xcode project using Carthage, specify it in your Cartfile:

github "malcommac/ScrollingStackContainer" ~> 0.5

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

Requirements

Current version is compatible with:

  • Swift 3.1+
  • iOS 8 or later

Credits & License

ScrollingStackContainer is owned and maintained by Daniele Margutti.

As open source creation any help is welcome!

The code of this library is licensed under MIT License; you can use it in commercial products without any limitation.

More Repositories

1

SwiftDate

🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
Swift
7,603
star
2

SwiftLocation

⚓️ Async/Await CLLocationManager Wrapper for Apple Platforms
Swift
3,386
star
3

SwiftRichString

👩‍🎨 Elegant Attributed String composition in Swift sauce
Swift
3,097
star
4

Hydra

⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Swift
1,973
star
5

Repeat

🕦 Modern Timer in Swift, Debouncer and Throttler (alternative to NSTimer) made with GCD
Swift
1,466
star
6

UIWindowTransitions

🏃‍♂️ Animated transitions for UIWindow's rootViewController property
Swift
472
star
7

ImageSizeFetcher

Finds the type/size of an image given its URL by fetching as little data as needed
Swift
440
star
8

ScrollStackController

🧩 Easy scrollable layouts in UIKit - an UIStackView which scroll and uses root views of child view controllers.
Swift
435
star
9

Owl

A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Swift
432
star
10

Flow

Declarative approach to populate and manage UITableViews (see https://github.com/malcommac/FlowKit)
Swift
423
star
11

SwiftSimplify

🥷 High-performance polyline simplification library - port of simplify.js
Swift
299
star
12

DMLazyScrollView

Lazy Loading UIScrollView for iOS (with support for infinite scrolling)
Objective-C
293
star
13

DMPagerViewController

DMPagerViewController is page navigation controller like the one used in Twitter or Tinder
Objective-C
278
star
14

FlowKit

A declarative type-safe framework for building fast and flexible list with Tables & Collection
Swift
211
star
15

DMCircularScrollView

Infinite/Circular Scrolling Implementation for UIScrollView
Objective-C
205
star
16

SwiftScanner

String Scanner in pure Swift (supports unicode)
Swift
171
star
17

SwiftMsgPack

💬 Fast & Lightweight MsgPack Serializer & Deserializer for Swift
Swift
154
star
18

DMSlidingCell

Swipe To Reveal UITableViewCell Implementation as like in Twitter
Objective-C
152
star
19

DMSplitView

New NSSplitView class with multiple subviews resize behaviors and animated transitions
Objective-C
116
star
20

DMScrollingTicker

Advanced horizontal scrolling ticker for iOS
Objective-C
110
star
21

DMDynamicWaterfall

UICollectionView Waterfall Layout with UIKit Dynamics
Objective-C
109
star
22

DMTabBar

XCode 4.x like inspector segmented control
Objective-C
108
star
23

HermesNetwork

Swift
72
star
24

DMInspectorPalette

Animated NSScrollView with collapsible sections like in XCode Inspector
Objective-C
61
star
25

SwiftUnistroke

✍️ $1 Unistroke Gesture Recognizer in Swift
Swift
53
star
26

UAParserSwift

🗺 User-Agent Parser based upon ua-parser.js
Swift
40
star
27

DMPageControl

An high customizable alternative to UIPageControl
39
star
28

DMTwitterOAuth

Twitter OAuth Library (Callback URL Login)
Objective-C
37
star
29

DMScrollViewStack

DMScrollViewStack is a UIScrollView subclass that efficiently handles a vertical stack of multiple scrollviews
Objective-C
33
star
30

DMLocationManager

Location Manager for iOS made simple
Objective-C
27
star
31

DMPathBar

XCode's Yosemite like path bar of OS X
Objective-C
25
star
32

Swift-Coding-Guidelines

A repository to collect best practices when programming with Swift
21
star
33

xcbetarunner

Run & Debug projects [easily] with stable Xcode on beta iOS devices
Swift
17
star
34

GitLabSwift

🛵 Async/Await GitLab REST APIs v4 for Swift
Swift
17
star
35

DMCacheBox

Fast advanced caching system for Objective-C (Cocoa/iOS compatible)
Objective-C
14
star
36

RealEventsBus

🚎 Simple type-safe event bus implementation in swift
Swift
13
star
37

DMMultiDelegatesProxy

Multiple delegate architecture made using NSProxy
Objective-C
10
star
38

Glider-Old

✈️ Fast & powerful logger for Swift
Swift
9
star
39

NSSplitView-Animatable

NSSplitView Category to perform simple animations with dividers
Objective-C
9
star
40

SlidingSheet

Configurable Bottom Sheet for UIKit - like AirBnb and Apple Maps
Swift
8
star
41

CircularScroller

Efficient and Lightweight endless UIScrollView implementation in Swift
Swift
7
star
42

DMAPNServer

APN - Apple Push Notification Server in PHP
PHP
6
star
43

DMCoreDataUtils

Utilities methods for Apple's Core Data Storage
Objective-C
6
star
44

sentry-cocoa-sdk-xcframeworks

A mirror for https://github.com/getsentry/sentry-cocoa to add support for binary (xcframework) distribution with swift package manager.
Shell
4
star
45

CAKeyFrameAnimation-Evaluators

Easily specify CAKeyFrameAnimation curves using C functions or ObjC Class
Objective-C
3
star
46

ZoomableListController

Apple's iOS Weather App List Imitation written in Swift
Swift
2
star
47

MeetingBot

Your next call on Mac status bar
Swift
2
star
48

Konsole

In-app Swift tools for great iOS developers
1
star
49

DMGrid

A simple 2D Grid class made in Objective-C
Objective-C
1
star
50

Envy

Type safe environment variables from shell processes and .env files
1
star