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 {
2121 self ? . delay ( 3 , closure: { [ weak self] in
2222 self ? . noDataMessage = " You don't have any search results. Please, refine your search criteria and try again. "
2323 self ? . customErrorTitle = " Hello World! "
24+ self ? . errorActionTitle = " Oops! "
2425 self ? . setVisibleScreen ( . Failure, actionHandler: {
2526
2627 } )
Original file line number Diff line number Diff line change 88
99Pod ::Spec . new do |s |
1010 s . name = 'LoadingViewController'
11- s . version = '0.2.0 '
11+ s . version = '0.2.1 '
1212 s . summary = 'LoadingViewController is a component for changing controller views: content -> loading -> content or content -> loading -> error.'
1313
1414# 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 {
4949 public var loadingViewColor : UIColor ?
5050 public var noDataViewColor : UIColor ?
5151 public var errorViewColor : UIColor ?
52+ public var errorActionTitle : String ? = NSLocalizedString ( " Try again " , comment: " " )
5253
5354 var visibleContentType : ContentType = . Undefined
5455 var activeView : UIView ?
@@ -90,6 +91,7 @@ public class LoadingViewController: UIViewController {
9091 view. title = errorTitle
9192 view. message = errorMessage
9293 view. image = errorIcon
94+ view. actionTitle = errorActionTitle
9395 return view
9496 }
9597
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ class ErrorView: UIView {
3131 didSetImage ( )
3232 }
3333 }
34+ var actionTitle : String ? {
35+ didSet {
36+ didSetActionTitle ( )
37+ }
38+ }
3439
3540 static func viewWithStyle( style: ErrorViewStyle , actionHandler: ActionHandler ? = nil ) -> ErrorView {
3641
@@ -46,4 +51,5 @@ class ErrorView: UIView {
4651 func didSetMessage( ) { }
4752 func didSetImage( ) { }
4853 func didSetAction( ) { }
54+ func didSetActionTitle( ) { }
4955}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class SimpleErrorView: ErrorView {
1515 @IBOutlet var titleLabel : UILabel !
1616 @IBOutlet weak var imageView : UIImageView !
1717 @IBOutlet var messageLabel : UILabel !
18+ @IBOutlet weak var actionButton : UIButton !
1819
1920 override func didSetTitle( ) {
2021 titleLabel? . text = title
@@ -31,6 +32,11 @@ class SimpleErrorView: ErrorView {
3132 imageView? . image = newImage
3233 }
3334
35+ override func didSetActionTitle( ) {
36+ guard let newTitle = actionTitle else { return }
37+ actionButton. setTitle ( newTitle, forState: . Normal)
38+ }
39+
3440 @IBAction func action( sender: AnyObject ) {
3541 action ? ( )
3642 }
Original file line number Diff line number Diff line change 7373 </constraints >
7474 <freeformSimulatedSizeMetrics key =" simulatedDestinationMetrics" />
7575 <connections >
76+ <outlet property =" actionButton" destination =" sNq-j4-dgH" id =" c6N-et-Xy9" />
7677 <outlet property =" imageView" destination =" pyy-8x-tJd" id =" CcE-BQ-SHz" />
7778 <outlet property =" messageLabel" destination =" bFX-MB-E6F" id =" QhM-rg-P1s" />
7879 <outlet property =" titleLabel" destination =" gfN-0e-n0e" id =" diR-Ym-7yZ" />
You can’t perform that action at this time.
0 commit comments