iosiphoneuisplitviewcontrolleruisplitview

getting wrong center of frame for detail view for UISplitView


learning SWIFT. I can't seem to access bounds from my view... no matter what platform I work in the bounds return the same values (600,600).

I have a graphView : UIView & controller embedded in a navigationController as the Detail of a SplitViewController.

I am trying to get the center of my graphView : UIView on screen (the Detail of the splitViewController), but center keeps returning a point too far to the right (in portrait)/bottom (in landscape).

I tried accessing it multiple ways, but maybe my understanding of it is wrong?

example: var screenCenter: CGPoint = convertPoint( center, fromView: superview)

    println("bounds are  \(bounds)") // view boundaries
    println("frame is at \(frame)")  // frame where the view resides
    println(" center is at       \(center)")
    println(" ScreenCenter is at \(screenCenter)")

(output)

bounds are  (0.0,0.0,600.0,600.0)
frame is at (0.0,0.0,600.0,600.0)
 center is at       (300.0,300.0)
 ScreenCenter is at (300.0,300.0)

-> how do I actually get to the center? Is SplitView geography joint master + detail?

-> it seem the x positioning is correct in portrait (but not the y), and the y is correct in portrait (but not the x)


Solution

  • SOLVED! the graphView in Storyboard was missing constraints and using the default 600,600 values. "Reset to Suggested Constraints" in storyboard with the view selected fixed the issue