Changing Frame Programmatically iOS 7? [closed]
Asked Answered
S

0

6

BEFORE READING "iOS 7 OMG DOWNVOTE"

The problem has been solved and is not related to iOS 7 at all. The problem was that with autolayout turned on, you cannot change the frame directly but must edit constraints instead.

So I have an app that is in the App Store and I you type in some UITextFields but some of the text fields were covered by the keyboard so I programmatically moved them up. Now I am working with the Xcode and iOS 7 betas and this functionality stopped working. Here is my code:

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    textFieldRect = textField.frame;
    textField.frame = CGRectMake(5, 80, self.view.frame.size.width-10, 31);
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
    textField.frame = textFieldRect;
}

I check with an NSLog for the width of textFieldRect and TextField.frame at the end of textFieldDidBeginEditing: and the values are different (as they should be), yet there is no visual change. I know there are other ways to protect the textField from the keyboard, but I would really prefer to get this working as I hope to animate it, and I know that there is no reason this would not be possible.

Stereochromy answered 16/6, 2013 at 5:15 Comment(9)
It's under NDA so you should use the forums on apple's developer site.Hobgoblin
I love this "this is under NDA, let's downvote it" attitude...Grandpapa
@H2CO3 I agree it's stupid to cite an NDA as the reason for a close vote or a down vote, it's equally misguided to post a question about an unfinished SDK on an unfinished OS.Laterality
Why is there an ios7 tag if iOS 7 questions are not allowed?Stereochromy
And its not like UITextFields are some sort of new thing that your not supposed to talk about yet...Stereochromy
@Laterality no, see meta.stackexchange.com/q/180573/183887Stipendiary
Regarding how to handle code under NDA see meta.stackexchange.com/q/94465/183887Stipendiary
@Stereochromy UITextField isn't new, but your problems running your code on the new OS are.Laterality
Got answer to this question on the Apple Dev Forums. Turns out it wasn't really related to iOS 7; the problem was that autolayout prevents the frame from changing programmatically like that.Stereochromy

© 2022 - 2024 — McMap. All rights reserved.