objective c - Resize on rotation -
i trying put uiscroll view on page fills page minus 10px margin around edge. have done. however, want uiscrollview resize device rotated, keeping 10px margin. code far is:
// screen dimensions, considering status bar scrollwidth = self.getscreensize.width // evaluates 1004 in landscape & 748 in portrait scrollheight = self.getscreensize.height // evaluates 728 in landscape & 984 in portrait scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(10,10,scrollwidth,scrollheight)]; [scrollview setautoresizingmask:uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight]; ... other stuff load scrollview content ... [self.view addsubview:scrollview];
when launch app, scrollview wider page, irrespective of orientation launch in. removing [scrollview setautoresizingmask..... line makes scrollview fit perfectly, doesn't react device rotation.
what doing wrong?
use shouldautorotatetointerfaceorientation
detect when screen going rotate, , change frame of scroll view:
cgrect frame = scrollview.frame //change frame scrollview.frame = frame;
Comments
Post a Comment