Guest User

Untitled

a guest
Jun 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. //ViewController 繼承 KeyboardDelegate
  2. ViewController: UIViewController, KeyboardDelegate {
  3. override func viewDidLoad() {
  4. super.viewDidLoad()
  5. // Do any additional setup after loading the view, typically from a nib.
  6. // 初始化鍵盤
  7. let keyboardView = MyKeyboard(frame: CGRect(x: 0, y: 0, width: 0, height: 300))
  8. // 當鍵盤有按鍵按下後,會通知ViewController
  9. keyboardView.delegate = self
  10. // 設定input為自定義鍵盤
  11. textField.inputView = keyboardView
  12. }
  13.  
  14. //並實作KeyboardDelegate中的keyWasTapped
  15. //實作delegate
  16. func keyWasTapped(input: Int) {
  17. textField.insertText(String(input))
  18. }
  19. }
Add Comment
Please, Sign In to add comment