Customization
I am working on a view in Xcode 5 that displays a set of text fields. To handle scrolling when the keyboard comes up, I use the scroll view to place my text fields. I use autorun.
Problem
I am struggling with an issue where extra space is added to the beginning of my scroll view at runtime. Like the insert for my scroll view, although I confirmed by registering that the inserts are zero.
In my implementation of viewDidLoad (), I do this to confirm the values โโ...
UIEdgeInsets contentInsets = UIEdgeInsetsZero; self.scrollView.contentInset = contentInsets; self.scrollView.scrollIndicatorInsets = contentInsets; self.scrollView.contentSize = self.scrollView.bounds.size; self.scrollView.contentOffset = CGPointMake(0.0, 0.0); NSLog(@"Content Size: %fx %f", self.scrollView.contentSize.height, self.scrollView.contentSize.width); NSLog(@"Bounds Size: %fx %f", self.scrollView.bounds.size.height, self.scrollView.bounds.size.width); NSLog(@"Frame Size: %fx %f", self.scrollView.frame.size.height, self.scrollView.frame.size.width); NSLog(@"Inset Size top: %f bottom: %f", self.scrollView.contentInset.top, self.scrollView.contentInset.bottom); NSLog(@"Scroll Inset Size top: %f bottom: %f", self.scrollView.contentInset.top, self.scrollView.contentInset.bottom);
Output:
2013-10-08 11:38:42.953 test[6440:a0b] Content Size: 455.000000 x 320.000000 2013-10-08 11:38:42.954 test[6440:a0b] Bounds Size: 455.000000 x 320.000000 2013-10-08 11:38:42.955 test[6440:a0b] Frame Size: 455.000000 x 320.000000 2013-10-08 11:38:42.955 test[6440:a0b] Inset Size top: 0.000000 bottom: 0.000000 2013-10-08 11:38:42.956 test[6440:a0b] Scroll Inset Size top: 0.000000 bottom: 0.000000
The space (insertion) added above my first text box seems to roughly correspond to the standard navigation headers, but this may be a coincidence.
In my scroll view, the height is set to 455 with a value of 64 so that it matches the navigation status bar and the tab bar at the bottom.
I have no messages about possible problems. The limitation of the upper and lower scroll spaces is positioned as 0 points (I suppose from the status columns and tabs.
When you start the application and view the extra space in the scroll, the scroll bars cover only the expected space (they do not include this extra space as part of the scrollable area).
Last remark. When I execute the keyboard notification logic. ( taken from an apple here ... ) The problem solves itself, no more space. What makes it look like a problem with initialization with what is configured in the storyboard?
Thank!
objective-c autolayout ios7 uiscrollview storyboard
Michael Bopp Oct 08 '13 at 16:08 2013-10-08 16:08
source share