# Keyboard Pushing Up Text Fields

**URL:** <https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899>\
**Category:** iOS Apprentice\
**Created:** [October 8, 2016, 3:42am UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899 "2016-10-08T03:42:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 8, 2016, 3:42am UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/1 "2016-10-08T03:42:41Z")

</div>

I am having an issue with the keyboard pushing up the text field out of view. When I close the keyboard or swipe down, the field comes back into view. It seems to go into affect when I pinned the field using auto layout

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [October 8, 2016, 4:28pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/2 "2016-10-08T16:28:40Z")

</div>

That should not happen. Can you double-check that you pinned the Text Field using the right constraints, and that you didn’t – inadvertently – put any constraints on the view controller that shouldn’t be there?

---

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 8, 2016, 5:28pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/3 "2016-10-08T17:28:08Z")

</div>

I definitely have checked multiple times and I even compared the constraints on each file compared to the UI Improvements. I went ahead and ran your code from the UI Improvements, and it has the same functionality/bug.

1. Run app on iPhone SE
2. Go into a new list
3. Click + to add new item
4. If keyboard is not active in sim, click command + k to open keyboard. (If keyboard is active, skip to step 7)
5. hit cancel
6. Click add again
7. Keyboard should open immediately when you go to this scene and push the text out of view

To get Text Field back,

1. command + k to hide keyboard, text field should show
2. command + k to bring back keyboard and everything should stay the same.

This is the most drastic on the SE in the simulator, but on my 6plus, it happens slightly on the add list page (presumably since there is more content on it?) so it seems that it is not just an xcode bug.

These screenshots are from the UI Improvements Project that came with the book:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/2/b/2b40c8ec585a041312eac2730c9dfdf1c9f41c4f.png)

---

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 8, 2016, 5:28pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/4 "2016-10-08T17:28:58Z")

</div>

Removing the keyboard:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/a/c/ac22a71b2863f86a28e36c90e68057cf4abb940c.png)

---

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 8, 2016, 5:30pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/5 "2016-10-08T17:30:36Z")

</div>

Adding keyboard back:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/f/c/fc3bdc0bd93c438d07e2884622f4ffda134bdddc.png)

Lastly, here is my github link to this project, though as I stated, seems to happen in both mine and the one from the book: [GitHub - kickinbahk/swift-checklists](https://github.com/kickinbahk/swift-checklists)

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [October 9, 2016, 9:47am UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/6 "2016-10-09T09:47:47Z")

</div>

Ah yes, I have seen this problem. This is definitely a bug in Xcode or the simulator. (After all, the app isn’t really doing anything special: it’s just a text field in a table view. And it has worked without problems since iOS 5.)

During the iOS 10 beta, Apple admitted there were problems with modally presented screens (like this is) and I suspect not all of these problems have been solved.

However, I haven’t seen it happen on an actual device, only on the simulator. Are you saying it happens on your 6 Plus device too?

(To get the text field back, you can also “pull down” on the screen, just like when you’d be scrolling it.)

---

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 9, 2016, 1:16pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/8 "2016-10-09T13:16:56Z")

</div>

Issue on the Edit Item page:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/3/e/3e5c94184a30f3a66b1cea0fcee44e6a408f9e3a.PNG)

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [October 9, 2016, 2:48pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/9 "2016-10-09T14:48:51Z")

</div>

OK, I guess it’s not a simulator bug then. ☹ It’s definitely something that didn’t happen before iOS 10. Let’s hope it is fixed in 10.1.

---

<div class="post-metadata">

**Author:** ![mory](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mory/32/50349_2.png) [@mory](https://forums.kodeco.com/u/mory)\
**Post date:** [October 9, 2016, 8:02pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/10 "2016-10-09T20:02:45Z")

</div>

Ah, well appreciate you taking the time to take a look 😄

---

<div class="post-metadata">

**Author:** ![aurora14](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aurora14/32/102585_2.png) [@aurora14](https://forums.kodeco.com/u/aurora14)\
**Post date:** [October 10, 2016, 4:42am UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/11 "2016-10-10T04:42:14Z")

</div>

I’ve come across the same problem just then (both on a physical device and the simulator). Oddly enough, I found that if either no constraints are set on the text field, or they’re only partially set (so a warning comes up), the keyboard doesn’t push up the text field. If all the constraints are set on the text field, then the issue appears.

This definitely hasn’t occurred in the iOS 9 (the 4.1 tutorials), as I’ve gone through those and everything worked perfectly. Looks like a bug in iOS 10, as mentioned earlier

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [October 10, 2016, 2:29pm UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/12 "2016-10-10T14:29:02Z")

</div>

Until this thread I didn’t realize it was related to the constraints, so it’s good to have that insight. 🙂

---

<div class="post-metadata">

**Author:** ![cherry](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/cherry/32/110937_2.png) [@cherry](https://forums.kodeco.com/u/cherry)\
**Post date:** [October 25, 2016, 7:35am UTC](https://forums.kodeco.com/t/keyboard-pushing-up-text-fields/20899/13 "2016-10-25T07:35:28Z")

</div>

This is a strange, but if we comment call to super.viewWillAppear(animated) both in ListDetailViewController and ItemDetailViewController this solve the problem:

```
override func viewWillAppear(_ animated: Bool) {
    // super.viewWillAppear(animated)
    textField.becomeFirstResponder()
}

```

Seems this is bug in iOS 10.
