Skip to content

Commit 55ecb28

Browse files
committed
Working on UITableView
1 parent 19999b3 commit 55ecb28

File tree

5 files changed

+44
-55
lines changed

5 files changed

+44
-55
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/Cacao/UIScrollView.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public protocol UIScrollViewDelegate: class {
569569

570570
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView)
571571

572-
func viewForZooming(in scrollView: UIScrollView) -> UIView
572+
func viewForZooming(in scrollView: UIScrollView) -> UIView?
573573

574574
func scrollViewWillBeginZooming(_ scrollView: UIScrollView, withView view: UIView)
575575

@@ -579,3 +579,28 @@ public protocol UIScrollViewDelegate: class {
579579

580580
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool
581581
}
582+
583+
public extension UIScrollViewDelegate {
584+
585+
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { }
586+
587+
func scrollViewDidScroll(_ scrollView: UIScrollView) { }
588+
589+
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { }
590+
591+
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { }
592+
593+
func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { }
594+
595+
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { }
596+
597+
func viewForZooming(in scrollView: UIScrollView) -> UIView? { return nil }
598+
599+
func scrollViewWillBeginZooming(_ scrollView: UIScrollView, withView view: UIView) { }
600+
601+
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView, atScale scale: Float) { }
602+
603+
func scrollViewDidZoom(_ scrollView: UIScrollView) { }
604+
605+
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { return true }
606+
}

Sources/Cacao/UITableView.swift

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,7 @@ open class UITableView: UIScrollView {
180180
/// Returns a reusable header or footer view located by its identifier.
181181
public func dequeueReusableHeaderFooterView(withIdentifier identifier: String) -> UITableViewHeaderFooterView? {
182182

183-
if let existingView = dequeue(with: identifier, cache: &cache.headerFooters) {
184-
185-
return existingView
186-
187-
} else if let registeredView = self.reuseIdentifiers.headerFooters[identifier] {
183+
if let registeredView = self.reuseIdentifiers.headerFooters[identifier] {
188184

189185
// create new cell
190186
switch registeredView {
@@ -986,7 +982,6 @@ private extension UITableView {
986982

987983
var sections = [Section]()
988984
var cells = (reusable: Set<UITableViewCell>(), cached: [IndexPath: UITableViewCell]())
989-
var headerFooters = [UITableViewHeaderFooterView]()
990985
}
991986

992987
struct ReuseIdentifiers {
@@ -1073,68 +1068,24 @@ private extension UITableView {
10731068

10741069
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
10751070

1076-
assert(tableView.dataSource == nil, "Requesting cell for table view with no data source set")
1077-
10781071
fatalError("Should never request cell for table view with default data source")
10791072
}
10801073
}
10811074

10821075
final class DefaultDelegate: UITableViewDelegate {
10831076

10841077
fileprivate init() { }
1085-
1086-
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
1087-
1088-
}
1089-
1090-
func scrollViewDidScroll(_ scrollView: UIScrollView) {
1091-
1092-
}
1093-
1094-
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
1095-
1096-
}
1097-
1098-
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
1099-
1100-
}
1101-
1102-
func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
1103-
1104-
}
1105-
1106-
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
1107-
1108-
}
1109-
1110-
func viewForZooming(in scrollView: UIScrollView) -> UIView {
1111-
1112-
}
1113-
1114-
func scrollViewWillBeginZooming(_ scrollView: UIScrollView, withView view: UIView) {
1115-
1116-
}
1117-
1118-
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView, atScale scale: Float) {
1119-
1120-
}
1121-
1122-
func scrollViewDidZoom(_ scrollView: UIScrollView) {
1123-
1124-
}
1125-
1126-
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
1127-
1128-
}
11291078
}
11301079
}
11311080

1081+
/// The style of the table view.
11321082
public enum UITableViewStyle: Int {
11331083

11341084
case plain
11351085
case grouped
11361086
}
11371087

1088+
/// The position in the table view (top, middle, bottom) to which a given row is scrolled.
11381089
public enum UITableViewScrollPosition: Int {
11391090

11401091
case none
@@ -1143,6 +1094,7 @@ public enum UITableViewScrollPosition: Int {
11431094
case bottom
11441095
}
11451096

1097+
/// The type of animation when rows are inserted or deleted.
11461098
public enum UITableViewRowAnimation: Int {
11471099

11481100
case fade
@@ -1156,9 +1108,19 @@ public enum UITableViewRowAnimation: Int {
11561108
case automatic = 100
11571109
}
11581110

1111+
/// Requests icon to be shown in the section index of a table view.
1112+
///
1113+
/// If the data source includes this constant string in the array of strings it returns
1114+
/// in `sectionIndexTitles(for:)`, the section index displays a magnifying glass icon at
1115+
/// the corresponding index location. This location should generally be the first title in the index.
11591116
// http://stackoverflow.com/questions/235120/whats-the-uitableview-index-magnifying-glass-character
11601117
public let UITableViewIndexSearch: String = "{search}"
11611118

1119+
/// The default value for a given dimension.
1120+
///
1121+
/// Requests that UITableView use the default value for a given dimension.
1122+
public let UITableViewAutomaticDimension: CGFloat = -1.0
1123+
11621124
open class UITableViewRowAction {
11631125

11641126

Sources/Cacao/UITableViewCell.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ open class UITableViewCell: UIView {
2828

2929
self.style = style
3030
self.reuseIdentifier = reuseIdentifier
31+
32+
super.init(frame: .zero)
3133
}
3234

3335
/// Prepares a reusable cell for reuse by the table view'€™s delegate.

Sources/CacaoDemo/ContentModeViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class ContentModeViewController: UIViewController {
4646

4747
label.text = "\(modes[0])"
4848

49-
label.color = UIColor.white
49+
label.textColor = UIColor.white
5050

5151
button = UIButton(frame: CGRect())
5252

0 commit comments

Comments
 (0)