38

When I try to add layout margins to a label on a TableViewCell, using the right panel on Xcode, I try to add Explicit Margins (top, Left, Bottom, Right). But, as soon as I input a number value, or tap the arrow to change the value, Xcode crashes.

I've attached a photo to show the panel I am trying to add the layout margins in, and where it crashes.

Any ideas why it wont let me adjust the margins?

Image - Edit Layout Margins Panel

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
EvanOgo
  • 541
  • 1
  • 4
  • 11
  • a error message would help please – applecrusher Nov 08 '16 at 03:53
  • 2
    "Xcode quit unexpectedly." <-- super helpful ;) – Kaolin Fire Nov 08 '16 at 21:03
  • 1
    My expectation this is a serious bug in xcode. I'm thinking I might try to edit the storyboard directly, but.... – Kaolin Fire Nov 08 '16 at 21:04
  • Yes, there is no error message, I get an on-screen prompt saying Xcode Quit Unexpectedly" – EvanOgo Nov 09 '16 at 22:46
  • 1
    Same here. xcode crashes every time I try to change the bottom margin of a label in a container. I am running xcode in a virtual machine. – Dawied Nov 20 '16 at 15:21
  • This seems to be a major issue in Xcode. Make sure to update to the latest version of Xcode. If it is not resolved yet you can check out Apple Bug Reporter via this [link](https://developer.apple.com/bug-reporting/) or directly sign in [here](https://bugreport.apple.com/) and create a bug report. – mcd Dec 23 '16 at 12:33
  • Still happening to me too. Came here looking for a solution. Come on Apple, step up your game. – SomeGuy Jan 17 '17 at 17:43
  • it Solved in this post [Xcode quits unexpectedly every time I open my project](http://stackoverflow.com/a/13600567/3992606) – mohsen Jan 23 '17 at 11:59
  • Clearing out xcuserdata did not solve this for me. – bencallis Jan 27 '17 at 11:13
  • 1
    Also having the same problem for a `UITextField` – Matt Le Fleur Mar 22 '17 at 10:36
  • Please file a bug, best case if you can reproduce it in a small project. http://bugreport.apple.com – Alistra Apr 14 '17 at 12:36
  • could you show or share the screenshot of your view navigator as well please...there could be some conflicted constraints – DILIP KOSURI Jul 12 '17 at 02:27
  • 1
    I think problem occur because of Width Constraint. First remove or disable width constraint then try to add/enable trailing constraint and then if required add width constraint. I think its work – Nimisha Ranipa Aug 09 '17 at 09:20
  • Try doing [this](https://stackoverflow.com/a/13600567/3577656) – Rajal Aug 22 '17 at 07:12

8 Answers8

1

try to clear the constraints, connect/ reconnect the outlet and apply new constraints.

mahdi
  • 439
  • 3
  • 15
1

Had that problem. Its Xcode bug. Already fixed, so don't worry :)

0

I was facing similar problem.

The answer that I found and which I used in real project (but for UICollectionView) was to get the outlet of CollectionViewFlowLayout and to define the margins (line spacing and item spacing) by myself in code.

For example

collectionViewFlowLayout.minimumLineSpacing = getCollectionViewWidth() * 0.05

Where getCollectionViewWidth() is a function, that returns the size of collection view (for different screens it will be different) and 0.05 is just random coefficient.

I hope it may someway help you, you can feel free to ask anything else.

If you have crash when you add margins on any view in your storyboard you can try to get their outlets as well and to redefine their frames. It's kinda bad style, but if you won't figure out the problem its the only one I can recommend to you and which I used myself.

Also try to Clean project by clicking Product - Clean in you task bar when in X-Code.

0

Xcode stores some user state information inside the Xcode project file, which is really a folder. That state information might have become corrupted. You can normally throw away everything inside your .xcodeproj folder except the project.pbxproj file. This might fix your problem.

Open up the folder containing your .xcodeproj file. Right-click the .xcodeproj file and choose Show Package Contents. Then throw away everything except the project.pbxproj file.

If you know what an Xcode workspace is, and you're actually making use of it, you might not have a project.xcworkspace file to throw away, or you might not want to throw it away. But if you don't know what an Xcode workspace is, then you're not using it so you can just throw away project.xcworkspace. Xcode will recreate it automatically.

see This Link

mohsen
  • 4,698
  • 1
  • 33
  • 54
0

Clear all the constraints and try from applying one by one. That way you can resolve this issue.

Hemanth
  • 66
  • 7
0

Please remove all the constraint applied and connected to the outlet. And Try to apply new constraints.

Some time we delete Outlet from you files .h or .m or swift file which was connected to view in Storyboard or xibs at that time this problem occurs.

Bhavesh Patel
  • 596
  • 4
  • 17
0

Clearing all constraints is the way to go. Look around every nook and cranny and right click every little thing in both your Main.storyboard and the ViewControllerScene menu to its immediate left. If you can get the formatting back to its most base level your constraints will work fine!

Mary Hitchings
  • 111
  • 1
  • 5
0

Clear all the constraints and try from applying one by one.and take .xib file and connecte with Table view Cell

Amit Jesani
  • 155
  • 2
  • 9