MainViewController
class MainViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout
MainViewConroller
set up other view controllers
-
This is a
UIView
that is placed on the TabBarDeclaration
Swift
@IBOutlet var tabBarView: TabBarView!
-
This is a
UICollectionView
that is used to save an ordered collection ofviewControllers
and present them using customizable layoutsDeclaration
Swift
@IBOutlet var collectionView: UICollectionView!
-
This is a variable to save a list of
UIView
sDeclaration
Swift
var views: [UIView]
-
List of
Viewcontrollers
Declaration
Swift
var viewControllers: [UIViewController?]
-
Customise View
- Setup CollectionView
- Setup TabbarView
- Init ViewControllers
- Setup Notification Centre
Declaration
Swift
func customisation()
-
Scroll the menu, this will be called when a notification is being sent with value didSelectMenu
Declaration
Swift
@objc func scrollViews(notification: Notification)
-
Hide the navigation bar, this will be called when a notification is being sent with value hide
Declaration
Swift
@objc func hideBar(notification: NSNotification)
-
Asks collectionView for the number of items in the specified section.
Declaration
Swift
func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int
Parameters
collectionView
The collection view requesting this information.
section
An index number identifying a section in collectionView. This index value is 0-based.
Return Value
The number of rows in section.
-
Asks collectionView for the cell that corresponds to the specified item in the collection view.
Declaration
Swift
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
Parameters
collectionView
The collection view requesting this information.
indexPath
The index path that specifies the location of the item.
Return Value
A configured cell object. You must not return nil from this method.
-
Asks the delegate for the size of the specified item’s cell.
Declaration
Swift
func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize
Parameters
collectionView
The collection view object displaying the flow layout.
indexPath
The index path of the item
collectionViewLayout
The layout object requesting the
Return Value
The width and height of the specified item. Both values must be greater than 0.
-
Tells the delegate when the user scrolls the content view within the receiver.
Declaration
Swift
func scrollViewDidScroll(_ scrollView: UIScrollView)
Parameters
scorllView
The scroll-view object in which the scrolling occurred.
-
Called after the controller's view is loaded into memory. Load
customisation
Declaration
Swift
override func viewDidLoad()
-
Deinitialization Function
Declaration
Swift
deinit