I have a viewcontroller. On my storyboard I have dragged a TextField onto it. In my code, I define a rect, that needs to be positioned relative to the text field, as follows:
CGRect autocompleteRect = CGRectMake(schoolField.frame.origin.x, schoolField.frame.origin.y + 70, schoolField.frame.size.width,autocompleteTableView.contentSize.height);
That works fine, until I embed my TextField in a UIView. The UIView itself is managed by auto layout to be positioned in the center of the Controllers .view.
I would say, that this should not be of any influence to the relative postion of my rect. However, it is:
Since the embedding of the TextField in a UIView, my rect is positioned differently, also depending on the screen size of the device I'm running it on.
So, I guess it's got something to do with AutoLayout,but I wouldn't know what I should tell my app to behave the way I want it to.
Thanks for your insights.
autocompleteRect
is a rect inside CredentialsContainer
, but you use it for a view which has been contained by UIViewController
's view
. That's why your autocompleteRect
has wrong position when you use.
To solve issue, you need to add the view which will use autocompleteRect
to CredentialsContainer
.
Hope this can make you more clearly.