Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous Layout with UITextField in the contentView of a static UITableViewCell

I am trying to add UITextFields to the contentViews of some static UITableViewCells. If I just add them directly to the cells in the storyboard, I get several of the following warning in Xcode 5:

Ambiguous Layout: Position is ambiguous for "Round Style Text Field".

If I then select the UITextFields and choose "Add Missing Constraints" in the storyboard, I then get this warning instead:

Misplaced View: Frame for "Round Style Text Field" will be different at run time.

In addition, I've tried adding constraints between the UITextField and the the contentView manually (by selecting those two views and trying to add a constraint), but it seems like none of the constraint options are available for that particular relationship (checkboxes are all disabled)

Here are some screenshots of the Storyboard: Static UITableViewCells with UITextFields in their contentView

Static UITableViewCells with UITextFields in their contentView, Added Missing Constraints

like image 914
Jamie Forrest Avatar asked Sep 30 '13 23:09

Jamie Forrest


2 Answers

In the view controller panel to the left of storyboard there will be a yellow circle with an arrow Arrow, click it.

Then in the new panel click the yellow triangle with a circle in the middle.

You should get three options:

  1. Update Frame - this will move the UI element to match the orange dotted box
  2. Update Constraint - this will update the constraints to match the current UI element
  3. Reset to suggested constraints - Xcode will do what it thinks is right

In your case update constraints should work

like image 185
LanceJeffrey Avatar answered Oct 06 '22 06:10

LanceJeffrey


I was having similar issues - unable to add ("Pin") constraints to the embedded UITextField, getting warnings about it, etc. The OP didn't specify, but from the screenshot it appears the static UITableViewCell's Style is set to one of the pre-defined types ("Left Detail", in particular).

I found that setting the Table View Cell "Style" dropdown to "Custom" will magically enable adding constraints to the UITextField, at the cost of having to re-build the pre-defined cell style yourself - e.g. adding the UILabel(s) and matching their alignment to the other cells.

like image 27
mygzi Avatar answered Oct 06 '22 07:10

mygzi