0

I've a problem that I can't solve because I'm missing a little detail to explain the following situation.

I've an UIView with a Vertical Space Constraint to be on the bottom on the screen.

On a 3.5", the origin of my UIView is (0,447). On a 4", the origin is the same but on the simulator's screen the UIView is at the good position (bottom).

I need this origin to put correctly my view according to the keyboard below.

It's important to note that this origin (0,447) is the origin I can read on Xcode thanks to Interface Builder. I'm catching this origin on the viewDidLoad method.

basicOriginCommentView = commentView.frame.origin;

I've join a screenshot of my Interface Builder. screenshot

Thank you for your help.

6
  • You want the UIVie to move up when the keyboard is displayed? and down again when its not? May 21, 2014 at 9:05
  • Exactly. This is perfectly working for a 3.5" because I have the good basicOriginCommentView. But for a 4" it's not working. This origin doesn't change while the commentView is well positioned. My only problem is to find why this origin is not changed even though the view is well positioned. Maybe it's because the basicOriginCommentView is caught before the commentView was positioned. Is it possible ? (I'm creating it on viewDidLoad method)
    – brcebn
    May 21, 2014 at 9:13
  • Why not attach this view to UIKeyboard's accessory view? That way it will always be displayed when the keyboard is presented? May 21, 2014 at 9:15
  • I didn't know that before developing this. Now it's working so I won't change everything. My only problem is about this view origin.. Everything works good after that. By the way if the implementation of this is easy to do, why not. Does this view always visible even if the keyboard is not ?
    – brcebn
    May 21, 2014 at 9:16
  • Could you give me an example of what you're thinking about ?
    – brcebn
    May 21, 2014 at 9:23

1 Answer 1

0

I tried different ways to solve this problem.

On Interface Builder, I manually increase the y to be perfectly align with the bottom for the 4" device. It was working perfectly for a 4" but I have the same problem for the 3.5".

Finally I saved the origin far after the viewDidLoad method. Just when my keyboard will appear, I save the position of the contentView. At this time the origin is the good one.

That means I have no idea why the origin was not good when I saved the origin on the viewDidLoad method.

Anyway, problem solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.