Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ViewController 繼承 KeyboardDelegate
- ViewController: UIViewController, KeyboardDelegate {
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
- // 初始化鍵盤
- let keyboardView = MyKeyboard(frame: CGRect(x: 0, y: 0, width: 0, height: 300))
- // 當鍵盤有按鍵按下後,會通知ViewController
- keyboardView.delegate = self
- // 設定input為自定義鍵盤
- textField.inputView = keyboardView
- }
- //並實作KeyboardDelegate中的keyWasTapped
- //實作delegate
- func keyWasTapped(input: Int) {
- textField.insertText(String(input))
- }
- }
Add Comment
Please, Sign In to add comment