Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# CHANGELOG

## 4.0.5
* Add support for automatic cell registration by conforming to 'AutoRegistering' (table view / collection view).
[@apptekstudios](https://github.com/apptekstudios)
[#63](https://github.com/AliSoftware/Reusable/pull/63)


## 4.0.5
* Fix for only allowing the use of app extension API.
[igorkulman](https://github.com/igorkulman)
[#73](https://github.com/AliSoftware/Reusable/pull/73)
Expand Down
29 changes: 17 additions & 12 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Reusable
* This view is NOT loaded from a NIB (but defined entierly by code),
* that's why it's not annotated as `NibLoadable` but only `Reusable`
*/
final class MyColorSquareCell: UICollectionViewCell, Reusable {
final class MyColorSquareCell: UICollectionViewCell, Reusable, AutoRegistering {
private lazy var colorView: UIView = {
let colorView = UIView()
colorView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
Expand Down
6 changes: 5 additions & 1 deletion Example/ReusableDemo iOS/CollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ final class CollectionViewController: UICollectionViewController {
guard let collectionView = self.collectionView else { return }

// Register cell classes
collectionView.register(cellType: MyColorSquareCell.self)
collectionView.register(cellType: MyXIBIndexSquaceCell.self)

/* Since MyColorSquareCell is marked as conforming to AutoRegistering,
there's no need to register this type ahead of time */
//collectionView.register(cellType: MyColorSquareCell.self)

// No need to register this one, the UIStoryboard already auto-register its cells
// self.collectionView.registerReusableCell(MyStoryBoardIndexPathCell)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Reusable
*
* That's why it's annotated with the `NibOwnerLoadable` protocol.
*/
final class MyHeaderTableView: UIView, NibOwnerLoadable {
final class MyTableViewHeader: UIView, NibOwnerLoadable {

@IBOutlet private weak var titleLabel: UILabel!
static let height: CGFloat = 55
Expand All @@ -30,6 +30,6 @@ final class MyHeaderTableView: UIView, NibOwnerLoadable {
}

func fillForSection(_ section: Int) {
self.titleLabel.text = "Header Section #\(section)"
self.titleLabel.text = "Header Section #\(section) (manual load)"
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MyHeaderTableView" customModule="ReusableDemo" customModuleProvider="target">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MyTableViewHeader" customModule="ReusableDemo_iOS" customModuleProvider="target">
<connections>
<outlet property="titleLabel" destination="hYf-aH-s8i" id="WZ1-Km-cgw"/>
</connections>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// MyAutoRegisterHeaderTableView.swift
// ReusableDemo
//
// Created by TJB on 07/08/18.
// Copyright © 2018 ApptekStudios. All rights reserved.
//

import UIKit
import Reusable

/**
* This view is loaded from a NIB, and is the XIB file's
* root view (and not the File's Owner). => it is `NibLoadable`
*
* It is also reusable and has a `reuseIdentifier` (as it's a TableViewHeaderFooterView
* and it uses the TableView recycling mechanism) => it is `Reusable`
*
* That's why it's annotated with the `NibReusable` typealias,
* Which in fact is just a convenience typealias that combines
* `NibLoadable` & `Reusable` protocols.
*/
final class MyTableViewHeaderAutoRegistering: UITableViewHeaderFooterView, NibReusable, AutoRegistering {

@IBOutlet private weak var titleLabel: UILabel!

static let height: CGFloat = 55

func fillForSection(_ section: Int) {
self.titleLabel.text = "Header Section #\(section)"
}
}
Loading