2

I would like it to appear the keyboard is pushing another view up. The problem is there is a UITabbar between the UIView I would like to animate in unison with the keyboard, problem being the UITabbar breaks up what would give that appearance. What I would really like to be able to do is detect when the keyboard is at the exact point my view then animate that view.

Is this possible without going into the private API's?

Too be clear I have the animation working, just working out a way to make it smoother. The effect I am trying to create is similar to the messages app, but there is a UITabbar between to UIView and the bottom of the screen.

Shiva
  • 20,575
  • 14
  • 82
  • 112
Michael
  • 1,241
  • 1
  • 13
  • 25
  • So, when the keyboard is up, the tabbar should be hidden, but the UIView has been pushed up? – nhgrif Dec 21 '13 at 01:14
  • Tabbar won't be hidden in the sense of setting a property. It will be hidden in the sense it will be under the keyboard, but that really doesn't change the issue of the tabbar creating a gap that the keyboard needs to travel before animation on the view needs to happen. – Michael Dec 21 '13 at 01:22
  • Actually just working out a formula for this instead of finding something in the API. – Michael Dec 21 '13 at 01:22
  • Right, I was just making sure I understood. – nhgrif Dec 21 '13 at 01:23

1 Answers1

2

Perhaps this will work...

The height of the keyboard on the iPhone is 216 pixels. The default animation duration for the keyboard display is 0.25 seconds.

The height for a tab bar is 44 pixels.

So, if you started the UIView transition animation afterDelay:((44.0/216.0) * 0.25), this should look right on an iPhone. Perhaps try and see?

If this works, it's pretty easy how to figure out for landscape, and iPad, etc.


Additionally, if this does work, in your final implementation, I would avoid hardcoding the 0.25.

Community
  • 1
  • 1
nhgrif
  • 61,578
  • 25
  • 134
  • 173
  • This is exactly what i started doing after my post, funny how you think of something when you post it. A lot of hard coded values here though. – Michael Dec 21 '13 at 01:41
  • Yea. In a final implementation, I wouldn't hardcode any of the numbers... but I don't have access to a Mac at home to test whether or not this would work, so this answer is sort of a guess. In the final implementation, I'd definitely get all these numbers dynamically, but this is good enough for a test to see whether it looked right and was worth pursuing at all. – nhgrif Dec 21 '13 at 01:44
  • Yeah for sure. You where thinking along the same line I was. I'll post a full solution when I get this working and accept your answer :). – Michael Dec 21 '13 at 01:45
  • If you post a full solution, you should simply upvote my answer and accept your own answer. – nhgrif Dec 21 '13 at 01:46
  • Your afterDelay gave me to right path, i was thinking timer before I saw that. But the performSelector after delay is great – Michael Dec 21 '13 at 01:48
  • 1
    its the right track, but the formula needs to take into account a difference of travel for the UIview being moved. So the speed of the animation will need to change as well. – Michael Dec 21 '13 at 02:18
  • The animation duration should be the keyboard animation duration minus the value sent to `afterDelay`, right? – nhgrif Dec 21 '13 at 03:13