EvanOgo
EvanOgo

Reputation: 551

Xcode 8 Adding Layout Margins Crash

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

Upvotes: 38

Views: 1491

Answers (8)

mohsen
mohsen

Reputation: 5078

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

Upvotes: 0

Amit Jesani
Amit Jesani

Reputation: 155

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

Upvotes: 0

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

Upvotes: 1

mahdi
mahdi

Reputation: 459

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

Upvotes: 1

Mary Hitchings
Mary Hitchings

Reputation: 111

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!

Upvotes: 0

Bhavesh Patel
Bhavesh Patel

Reputation: 596

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.

Upvotes: 0

Hemanth
Hemanth

Reputation: 66

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

Upvotes: 0

Олег Місько
Олег Місько

Reputation: 370

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.

Upvotes: 0

Related Questions