diff --git a/Source/ASViewController.h b/Source/ASViewController.h index 94863298..89c02d6f 100644 --- a/Source/ASViewController.h +++ b/Source/ASViewController.h @@ -38,6 +38,15 @@ typedef ASTraitCollection * _Nonnull (^ASDisplayTraitsForTraitWindowSizeBlock)(C */ - (instancetype)initWithNode:(DisplayNodeType)node NS_DESIGNATED_INITIALIZER; +/** +* ASViewController initializer. Useful for interoperability with normal UIViewControllers. +* +* @return An ASViewController instance with a nil node whose root view will be backed by a standard UIView as with a normal UIViewController. +* +* @see ASVisibilityDepth +*/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + NS_ASSUME_NONNULL_END /** diff --git a/Source/ASViewController.mm b/Source/ASViewController.mm index a15a2144..6bc85566 100644 --- a/Source/ASViewController.mm +++ b/Source/ASViewController.mm @@ -64,6 +64,17 @@ return self; } +- (instancetype)init +{ + if (!(self = [super initWithNibName:nil bundle:nil])) { + return nil; + } + + [self _initializeInstance]; + + return self; +} + - (void)_initializeInstance { if (_node == nil) { diff --git a/examples/CustomCollectionView-Swift/Sample/ViewController.swift b/examples/CustomCollectionView-Swift/Sample/ViewController.swift index 3af62907..1e33a06f 100644 --- a/examples/CustomCollectionView-Swift/Sample/ViewController.swift +++ b/examples/CustomCollectionView-Swift/Sample/ViewController.swift @@ -17,7 +17,7 @@ class ViewController: ASViewController, MosaicCollectionViewLa let _layoutInspector = MosaicCollectionViewLayoutInspector() let kNumberOfImages: UInt = 14 - init() { + override init() { let layout = MosaicCollectionViewLayout() layout.numberOfColumns = 3; layout.headerHeight = 44; diff --git a/examples/LayoutSpecExamples-Swift/Sample/OverviewViewController.swift b/examples/LayoutSpecExamples-Swift/Sample/OverviewViewController.swift index f306a12f..0c9110a3 100644 --- a/examples/LayoutSpecExamples-Swift/Sample/OverviewViewController.swift +++ b/examples/LayoutSpecExamples-Swift/Sample/OverviewViewController.swift @@ -13,7 +13,7 @@ class OverviewViewController: ASViewController { let tableNode = ASTableNode() let layoutExamples: [LayoutExampleNode.Type] - init() { + override init() { layoutExamples = [ HeaderWithRightAndLeftItems.self, PhotoWithInsetTextOverlay.self, diff --git a/examples/Swift/Sample/ViewController.swift b/examples/Swift/Sample/ViewController.swift index 0c94d86a..8384906c 100644 --- a/examples/Swift/Sample/ViewController.swift +++ b/examples/Swift/Sample/ViewController.swift @@ -29,7 +29,7 @@ final class ViewController: ASViewController, ASTableDataSource, fileprivate(set) var state: State = .empty - init() { + override init() { super.init(node: ASTableNode()) tableNode.delegate = self tableNode.dataSource = self