###前提・実現したいこと
SwiftのXcode内のエミュレーターでキーボードが表示されない。
現在、メモアプリを作っている。
###発生している問題・エラーメッセージ
特にエラーは発生していない。
AppDelegate.swiftに
###該当のソースコード
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var lastText: String? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. let userDefaults = UserDefaults.standard lastText = userDefaults.object(forKey: "lastText") as? String return true } func applicationWillResignActive(_ application: UIApplication) { let userDefaults = UserDefaults.standard userDefaults.set(lastText, forKey: "lastText") } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } }
と書いてViewController.swiftに
import UIKit class ViewController: UIViewController, UITextViewDelegate { @IBOutlet weak var textView: UITextView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. textView.delegate = self let appDelegate = UIApplication.shared.delegate as! AppDelegate textView.text = appDelegate.lastText } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func textViewDidChange(_ textView: UITextView) { let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.lastText = textView.text } }
と書いた。
###試したこと
キーボードを表示させるキーボードを押していないのかソースコード上に問題があるのかわからない。
「前提・実現したいこと」に何を実現したいのかを具体的に書いてください。(例:画面を開いたときにソフトウェアキーボードが入力状態になること)。「発生している問題・エラーメッセージ」には例外等は発生していないとのことですが、期待した動作にならないことも「問題」として記述ください。「試したこと」には問題を解決するためにどのような試みをしたかや参考にしたサイトを書いてください。
Macのキーボードからは文字を入力できますか?実機(iPhone/iPad)ではソフトウェアキーボードが表示されるのでしょうか?
Macからも実機からもキーボード入力ができません
念のため確認しますが、TextViewをタップしてますか? タップしたときにカーソルは表示されますか?
はいタップしています。タップしたときにカーソルは表示されません。
TextViewのEditableのチェックが外れていませんか?
それはどこから確認できますか?Swift3を使っています。KeyboardのDo not dismiss のことでしょうか?
Storyboardです。
質問文にStoryboardの写真を追加しました。Editingが見当たらず。。。ここではないのでしょうか?
EditableはText Viewのところにあります。(2枚目の画像)チェックは入っているので問題なさそうです。
なるほど。。。では何が問題なのでしょうか?
一度、新規のプロジェクトを作成し、TextViewだけ配置して実行して試してみて下さい。(コードは何も書かなくてかまいません)