-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTableViewController.swift
More file actions
49 lines (42 loc) · 1.29 KB
/
Copy pathTableViewController.swift
File metadata and controls
49 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// TableViewController.swift
// Example
//
// Created by Anton Malygin on 14.09.2021.
//
import UIKit
class TableViewController: UITableViewController {
private var scrollDirection: UICollectionView.ScrollDirection = .vertical
@IBAction private func changeScrollDirection(_ sender: UIBarButtonItem) {
if scrollDirection == .vertical {
scrollDirection = .horizontal
} else {
scrollDirection = .vertical
}
sender.title = scrollDirection.title
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender _: Any?) {
guard let identifier = segue.identifier else {
return
}
let controller = segue.destination as? ViewController
controller?.scrollDirection = scrollDirection
if let rows = Int(identifier) {
controller?.rowsPerSection = rows
}
}
}
extension UICollectionView.ScrollDirection {
var title: String {
switch self {
case .vertical:
return "Vertical"
case .horizontal:
return "Horizontal"
@unknown default:
fatalError("Unknown direction")
}
}
}