File tree Expand file tree Collapse file tree 6 files changed +17
-1
lines changed
Example/LoadingViewController
LoadingViewController/Classes Expand file tree Collapse file tree 6 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class ViewController: LoadingViewController {
21
21
self ? . delay ( 3 , closure: { [ weak self] in
22
22
self ? . noDataMessage = " You don't have any search results. Please, refine your search criteria and try again. "
23
23
self ? . customErrorTitle = " Hello World! "
24
+ self ? . errorActionTitle = " Oops! "
24
25
self ? . setVisibleScreen ( . Failure, actionHandler: {
25
26
26
27
} )
Original file line number Diff line number Diff line change 8
8
9
9
Pod ::Spec . new do |s |
10
10
s . name = 'LoadingViewController'
11
- s . version = '0.2.0 '
11
+ s . version = '0.2.1 '
12
12
s . summary = 'LoadingViewController is a component for changing controller views: content -> loading -> content or content -> loading -> error.'
13
13
14
14
# This description is used to generate tags and improve search results.
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ public class LoadingViewController: UIViewController {
49
49
public var loadingViewColor : UIColor ?
50
50
public var noDataViewColor : UIColor ?
51
51
public var errorViewColor : UIColor ?
52
+ public var errorActionTitle : String ? = NSLocalizedString ( " Try again " , comment: " " )
52
53
53
54
var visibleContentType : ContentType = . Undefined
54
55
var activeView : UIView ?
@@ -90,6 +91,7 @@ public class LoadingViewController: UIViewController {
90
91
view. title = errorTitle
91
92
view. message = errorMessage
92
93
view. image = errorIcon
94
+ view. actionTitle = errorActionTitle
93
95
return view
94
96
}
95
97
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ class ErrorView: UIView {
31
31
didSetImage ( )
32
32
}
33
33
}
34
+ var actionTitle : String ? {
35
+ didSet {
36
+ didSetActionTitle ( )
37
+ }
38
+ }
34
39
35
40
static func viewWithStyle( style: ErrorViewStyle , actionHandler: ActionHandler ? = nil ) -> ErrorView {
36
41
@@ -46,4 +51,5 @@ class ErrorView: UIView {
46
51
func didSetMessage( ) { }
47
52
func didSetImage( ) { }
48
53
func didSetAction( ) { }
54
+ func didSetActionTitle( ) { }
49
55
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class SimpleErrorView: ErrorView {
15
15
@IBOutlet var titleLabel : UILabel !
16
16
@IBOutlet weak var imageView : UIImageView !
17
17
@IBOutlet var messageLabel : UILabel !
18
+ @IBOutlet weak var actionButton : UIButton !
18
19
19
20
override func didSetTitle( ) {
20
21
titleLabel? . text = title
@@ -31,6 +32,11 @@ class SimpleErrorView: ErrorView {
31
32
imageView? . image = newImage
32
33
}
33
34
35
+ override func didSetActionTitle( ) {
36
+ guard let newTitle = actionTitle else { return }
37
+ actionButton. setTitle ( newTitle, forState: . Normal)
38
+ }
39
+
34
40
@IBAction func action( sender: AnyObject ) {
35
41
action ? ( )
36
42
}
Original file line number Diff line number Diff line change 73
73
</constraints >
74
74
<freeformSimulatedSizeMetrics key =" simulatedDestinationMetrics" />
75
75
<connections >
76
+ <outlet property =" actionButton" destination =" sNq-j4-dgH" id =" c6N-et-Xy9" />
76
77
<outlet property =" imageView" destination =" pyy-8x-tJd" id =" CcE-BQ-SHz" />
77
78
<outlet property =" messageLabel" destination =" bFX-MB-E6F" id =" QhM-rg-P1s" />
78
79
<outlet property =" titleLabel" destination =" gfN-0e-n0e" id =" diR-Ym-7yZ" />
You can’t perform that action at this time.
0 commit comments