Skip to content

Commit

Permalink
Override becomeFirstResponder in LSCreditCardFormView
Browse files Browse the repository at this point in the history
This allows user to programmatically show open keyboard, useful if the goal is to have keyboard open immediately when view is presented
  • Loading branch information
Lope committed Jun 6, 2018
1 parent 70a96b0 commit 86aa5a6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
16 changes: 8 additions & 8 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LSCreditCardForm.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'LSCreditCardForm'
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = 'Simple and engaging credit card form'

s.description = <<-DESC
Expand Down
7 changes: 7 additions & 0 deletions LSCreditCardForm/Classes/LSCreditCardFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ public class LSCreditCardFormView: UIView {
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[buttons]|", options: [], metrics: nil, views: views))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[ccWrapper][textFields(70)][buttons(50)]|", options: [], metrics: nil, views: views))
}

override public func becomeFirstResponder() -> Bool {
super.becomeFirstResponder()

return viewTextFields.becomeFirstResponder()
}

}
7 changes: 7 additions & 0 deletions LSCreditCardForm/Classes/LSTextFieldsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ class LSTextFieldsView: UIView {

changingResponderFromCode = false
}

override public func becomeFirstResponder() -> Bool {
super.becomeFirstResponder()

return tfNumber.becomeFirstResponder()
}

}

extension LSTextFieldsView: UITextFieldDelegate {
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ If you wish to limit which credit cards get detected, override `CreditCard.suppo
want to detect. User will still be able to enter any credit card number, disabling detection for certain types simply means that the credit
card image will not update and will remain on "unknown" credit card.

## Keyboard

If you wish to have keyboard open as soon as the view appears with new view controller, call `becomeFirstResponder` on `LSCreditCardFormView`.

## Installation

LSCreditCardForm is available through [CocoaPods](http://cocoapods.org). To install
Expand Down

0 comments on commit 86aa5a6

Please sign in to comment.