File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
ViewRelated/Orders/OrderDetails/AddNote Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Foundation
22import UIKit
33
44
5- /// UIView Helper Methods
5+ /// UIView Class Methods
66///
77extension UIView {
88
@@ -19,3 +19,23 @@ extension UIView {
1919 return loadNib ( ) . instantiate ( withOwner: nil , options: nil ) . first as! T
2020 }
2121}
22+
23+
24+ /// UIView Extension Methods
25+ ///
26+ extension UIView {
27+
28+ /// Returns the first Subview of the specified Type (if any).
29+ ///
30+ func firstSubview< T: UIView > ( ofType type: T . Type ) -> T ? {
31+ for subview in subviews {
32+ guard let target = ( subview as? T ) ?? subview. firstSubview ( ofType: type) else {
33+ continue
34+ }
35+
36+ return target
37+ }
38+
39+ return nil
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,16 @@ class AddANoteViewController: UIViewController {
2727 loadSections ( )
2828 }
2929
30+ override func viewDidAppear( _ animated: Bool ) {
31+ super. viewDidAppear ( animated)
32+ tableView. firstSubview ( ofType: UITextView . self) ? . becomeFirstResponder ( )
33+ }
34+
35+ override func viewWillDisappear( _ animated: Bool ) {
36+ super. viewWillDisappear ( animated)
37+ view. endEditing ( true )
38+ }
39+
3040 func configureNavigation( ) {
3141 title = NSLocalizedString ( " Order # \( viewModel. order. number) " , comment: " Add a note screen - title. Example: Order #15 " )
3242
You can’t perform that action at this time.
0 commit comments