J W
J W

Reputation: 878

Positioning UIControls in UITableViewCells in Interface Builder

So I have a UITableView in a .xib file. That's all that's in it.

In the cellForRowAtIndexPath method, I use a custom UITableViewCell. The UITableViewCell width in IB is 320.

I dropped in a UISegmentedControl and centered it per the blue guide lines. When I present the table in a popover, the UISegmentedControl in the UITableViewCell is not centered. It's like the UITableViewCell gets cut off. I included a picture.

Is there something that I am forgetting in the sizes of things? I have another 4 segmented control where although the segmented control shows in the UITableViewCell, it is cut off. My contenstSizeForPopover is set to 320 for the width also.

enter image description here

Upvotes: 0

Views: 155

Answers (1)

rob mayoff
rob mayoff

Reputation: 385710

When you put the cell into a group table view, the cell makes its content area 20 points narrower to allow for table border/background area. That's why your controls are getting cut off.

You can probably just set your controls to have flexible width:

autosizing with flexible width

but you'll have to keep the resizing in mind when you design your cell layout.

Upvotes: 1

Related Questions