iphone - Full Screen UIScrollView not working Correctly -
i have application photos app main view uiscrollview takes full size of screen. also, photos app, when user taps screen there translucent navigation, status, , tool bars reappear / disappear.
i having problem setting uiviewcontrollers main view uiscrollview , having take full length of screen. problem when navigation , status bars shown, uiscrollview gets pushed down height of navigation , status bars (it doesn't go underneath them it's suppose to). when user taps screen , navigation / status bars disappear, resets take full length of screen it's suppose to.
a simple work around of setting main view uiview , attaching uiscrollview on top of works. however, i'd try , work without workarounds (ie adjusting uiscrollviews contentinset, etc) because in theory should work.
below code i'm implementing:
- (void)loadview { self.wantsfullscreenlayout = yes; uiscrollview *scrollview = [[uiscrollview alloc] initwithframe: cgrectmake(0,0,320,480)]; scrollview.contentsize = cgsizemake(320, 480); scrollview.scrollenabled = no; scrollview.contentoffset = cgpointzero; scrollview.bounces = no; self.view = scrollview; [scrollview release]; } - (void) viewwillappear:(bool)animated { [super viewwillappear:animated]; self.navigationcontroller.navigationbar.translucent = yes; [[uiapplication sharedapplication] setstatusbarstyle: uistatusbarstyleblacktranslucent animated: no]; self.navigationcontroller.toolbarhidden = no; self.navigationcontroller.toolbar.barstyle = uibarstyleblack; self.navigationcontroller.toolbar.translucent = yes; [self starttimer]; } - (void) viewwilldisappear:(bool)animated { [super viewwilldisappear:animated]; self.navigationcontroller.navigationbar.translucent = no; [[uiapplication sharedapplication] setstatusbarstyle: uistatusbarstyledefault animated: no]; [self canceltimer]; } update: i've noticed it's contentoffset , contentinset changing, not scrollviews frame. when bars have disappeared , uiscrollview full size of screen (as should be), contentoffset , contentinset follows:
content offset: {0, -20} content inset: {20, 0, 44, 0} when bars visible , uiscrollview pushed down, contentoffset , contentinset follows:
content offset: {0, -64} content inset: {64, 0, 44, 0}
i solved similar issue on ios7 after reading apple's ui transition guide: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/appearancecustomization.html
it turns out uiviewcontroller has automaticallyadjustsscrollviewinsets boolean property. default true, disabling made uiscrollview fill entire window, instead of being pushed down.
Comments
Post a Comment