前提・実現したいこと
textViewの下の方を入力する際にキーボードでtextViewが隠れてしまいます。
上にずらすのではなく、textViewの高さをキーボードの表示に応じて変えられるようにしたいです。。。
該当のソースコード
上にずらす方法など試してみましたがじっくりこず、今は特に何もしていないです。。
このコードに書き込む予定でいます。
import UIKit import RealmSwift class memoViewController: UIViewController,UINavigationControllerDelegate, UITextViewDelegate { // var currentMemo = "" var itemBox = ItemBox() var receiveitemBox: ItemBox? var todoItems: Results<ItemBox>! @IBOutlet weak var memoBoxHeight: NSLayoutConstraint! @IBOutlet weak var memoBox: UITextView! override func viewDidLoad() { memoBox.delegate = self let realm = try! Realm() todoItems = realm.objects(ItemBox.self) memoBox.text = itemBox.memo print(itemBox) title = itemBox.title super.viewDidLoad() navigationController?.delegate = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { if viewController is ViewController { let realm = try! Realm() try! realm.write({ itemBox.memo = memoBox.text print(memoBox) }) } } }
どなたかよろしくお願いいたします。。
あなたの回答
tips
プレビュー