Search code examples
iosautolayoutui-design

Adding UIButton to custom cell with auto layout


I am trying to add a button through IB in a custom cell at top right corner of the cell. I am using auto layout to position it correctly but in simulator I don't know why the button wont show up.

But if i create it programmatically then it shows up perfectly.

So my question is how can achieve it using IB and where i am doing it wrong.

I have added four constraints on my button leading and trailing space to superview and fix width and height.


Solution

  • Remove leading space constrain and add fix to top space constrain. I mean there will be total 4 constrains Fixed width, height and fixed trailing, top space to super view and it will work. If it is not working means you have not set your tableView constrains. For tableView fix it from top,bottom,left and right space from super view.