ios - A container view and scroll view present an representation which is offset -
ios - A container view and scroll view present an representation which is offset -
i have app uiscrollview contains ui elements. 1 of elements in container has embedded uiviewcontroller uiscrollview containing uiimage , uilabels drawn on it.
i having problem presentation in uiscrollview of container, uiimage, supposed filling whole scrollable content, there bar @ top. offset annoying, throws off calculation of points. (the image supposed fill whole rounder border.
i set size (using constrains) of container view in viewdidload of containing uiviewcontroller (and result, box, expected):
[self floorplancontainerwidthconstraint].constant = [self view].frame.size.width - self.marginwidthconstraint.constant * 2; if([delegate isipad]){ [self floorplancontainerheightconstraint].constant = 300; } [_floorplancontainer layoutifneeded];
then in uiviewcontroller of container, on viewwilldisplay, update uiimageview dimensions contained edges of scrollview distance '0':
[super viewwillappear:animated]; [self imagecontainerheightconstraint].constant = [self parentview].frame.size.height; [self imagecontainerwidthconstraint].constant = [self parentview].frame.size.width; [_imageview layoutifneeded]; [_scrollview layoutifneeded]; nslog(@"parent frame: %f, %f, location %f, %f", [self parentview].frame.size.width, [self parentview].frame.size.height, [self parentview].frame.origin.x, [self parentview].frame.origin.y); nslog(@"image frame: %f, %f, location %f, %f", _imageview.frame.size.width, _imageview.frame.size.height, _imageview.frame.origin.x, _imageview.frame.origin.y); nslog(@"scroll frame: %f, %f, location %f, %f", _scrollview.frame.size.width, _scrollview.frame.size.height, _scrollview.frame.origin.x, _scrollview.frame.origin.y); nslog(@"content frame: %f, %f, location %f, %f", _scrollview.contentsize.width, _scrollview.contentsize.height, _scrollview.contentoffset.x, _scrollview.contentoffset.y); nslog(@"scroll frame zoom %f", [_scrollview zoomscale]);
the console output expected (i think):
parent frame: 351.000000, 200.000000, location 12.000000, 41.000000 image frame: 351.000000, 200.000000, location 0.000000, 0.000000 scroll frame: 351.000000, 200.000000, location 0.000000, 0.000000 content frame: 351.000000, 200.000000, location 0.000000, 0.000000 scroll frame zoom 1.000000
this suggests content frame same size scroll view , image, bu how content bigger (the bar seen) while values don't back upwards that? can scroll image vertically, while should fit (horizontal fits).
if reposition container view lower on layout becomes better, there fishy. have spend few hours trying figure wrong, cannot find it, suggestions really appreciated!
try set self.edgesforextendedlayout = uirectedgenone
.
ios objective-c iphone uiscrollview
Comments
Post a Comment