Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
997 views
in Technique[技术] by (71.8m points)

ios - What is the reason for the remaining vertical spacing between an "inner"-view and the contentview of an UITableViewCell using Storyboard?

I am using storyboard in an iOS/xcode project with the following simplified "hierarchy" (from top to bottom):

  • ViewController (not a TableViewController for some customizing reasons)
  • View
  • TableView (and some other content that does not matter I think)
  • Cell
  • ContentView
  • "AnyView" (specific type seems to be irrelevant, as the following happens for every item I tried)

When I set the constraints between AnyView and ContentView to Zero Spacing for Top/Bottom/Leading/Trailing there is still quite some "space" between the ContentView and AnyView. (I have never encountered this when doing similar things just programmatically.)

In order to get rid of that spacing I looked for everything in storyboard options that sounded even remotely like spacing / intending etc., but did not really succeed.

By accident I just realized that when I drag & drop a view into the ContentView in a certain way it appears that storyboard sets a negative spacing of -8 that seems to "remove" that spacing. I could just use that number in my constraints, but it seems somewhat random. Does anyone know what the reason for my unwanted spacing might be or if that -8 has a deeper meaning (e.g. maybe Apple is forcing some design guidelines onto storyboard users that way?)?

Thank you very much for any insights!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Xcode 6 constraints can be "relative to margin". The margin is set as the normal default spacing to the edge of the screen.

You can turn this off in the "add constraints" button...

enter image description here

Or in the constraint property inspector...

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...