Repository navigation
Expand file tree
/
Copy pathViewController.swift
More file actions
88 lines (73 loc) · 2.65 KB
/
Copy pathViewController.swift
File metadata and controls
88 lines (73 loc) · 2.65 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// ViewController.swift
// Example
//
// Copyright © 2016 Xmartlabs SRL. All rights reserved.
//
import ImageRow
import Eureka
class ViewController: FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
form +++ Section()
<<< ImageRow() { row in
row.title = "Image Row 1"
row.sourceTypes = [.PhotoLibrary, .SavedPhotosAlbum]
row.clearAction = .yes(style: UIAlertAction.Style.destructive)
}
+++
Section()
<<< ImageRow() {
$0.title = "Image Row 2"
$0.sourceTypes = .PhotoLibrary
$0.clearAction = .no
}
.cellUpdate { cell, row in
cell.accessoryView?.layer.cornerRadius = 17
cell.accessoryView?.frame = CGRect(x: 0, y: 0, width: 34, height: 34)
}
+++
Section()
<<< MyImageRow() {
$0.title = "Image Row 3"
$0.sourceTypes = [.PhotoLibrary, .SavedPhotosAlbum]
$0.clearAction = .yes(style: .default)
}
}
}
/// CustomPickerController: a selector row where the user can pick an image and edit it then of the selection
public final class MyImageRow: _ImageRow<PushSelectorCell<UIImage>>, RowType {
public required init(tag: String?) {
super.init(tag: tag)
// Set a nib file to the cell privider
cellProvider = CellProvider<PushSelectorCell<UIImage>>(nibName: "CustomRow", bundle: Bundle.main)
}
}
/// Definition of a custom cell
public final class MyImageCell: PushSelectorCell<UIImage> {
/// xib outlets
@IBOutlet weak public var myImageView: UIImageView!
@IBOutlet weak var myLabel: UILabel!
/// Required inits
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
fatalError("init(style:reuseIdentifier:) has not been implemented")
}
/// Override the setup to change the cell height
public override func setup() {
super.setup()
height = { return 80 }
}
/// Cell update - The image selected in the row will appear in the imageView (outlet)
public override func update() {
super.update()
if let image = row.value {
myImageView.image = image
}
myLabel.text = row.title
textLabel?.text = nil
detailTextLabel?.text = nil
}
}