iphone - iOS7 - View under status bar - edgesForExtendedLayout not working -
i have project built last year, , uses xibs, no storyboards. xibs not use auto layout, use autosizing. have issue when running ios7, in views tucked under status bar. understand new feature ios7, in can expected. however, of solutions fixing not not working. have image @ top of view shows under status-bar, , i'm not using nav-bars or that.
i have tried updating y-deltas in xib (they have no effect on view), have tried setting edgesforextendedlayout
uirectedgenone
(does nothing), , multitude of other things. every time, status bar shows view tucked under it, no matter do.. unless manually move down view in xib allow room status bar (but solution doesn't work because doesn't right in ios6, of course).
what's odd when try line of code hack in view-shift, doesn't work (like following):
self.view.frame = cgrectmake(self.view.frame.origin.x, self.view.frame.origin.y+20, self.view.frame.size.width, self.view.frame.size.height);
..not go kind of solution, it's odd didn't work (the time typically see not work if auto layout in place, it's not in case).
it design requirement status-bar shows, , i'm stumped on why can't set view under status bar ios7. have read every single stack overflow post on subject, apple's transition/guides. once again, reiterate, understand how should function , expected solution should this, none of seems working particular project.
i experienced ios dev, project built team, don't know if there's hidden somewhere in xib files, plist, or code trumping above settings. please let me know if there else can looked @ on this, or more information can provide.
thanks in advance!
if set ios 6/7 delta values in interface builder, remember set "view as" "ios 6" on interface builder document, since ios 6 layout want replicate. deltas used on ios 7 push content below status bar. if leave "view as" set ios 7 (the default) deltas instead give ios 7 on ios 6.
however, deltas not if reposition or resize views programmatically based on view frame, since frame not account deltas.
instead of using deltas, best solution have found enable auto layout on main xib , set top space constraint on top/content view follow top layout guide. guide introduced in ios 7 , represents position below status bar. unfortunately guide not available in interface builder when not using storyboards, can add programmatically.
what did add top space constraint superview instead in interface builder, , created outlet in code. then, in viewdidload, if toplayoutguide available (ios 7+), replace constraint in outlet version using top layout guide instead.
if ([self respondstoselector:@selector(toplayoutguide)]) { [self.view removeconstraint:self.containertopspaceconstraint]; self.containertopspaceconstraint = [nslayoutconstraint constraintwithitem:self.contentview attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:self.toplayoutguide attribute:nslayoutattributebottom multiplier:1 constant:0]; [self.view addconstraint:self.containertopspaceconstraint]; [self.view setneedsupdateconstraints]; [self.view layoutifneeded]; }
Comments
Post a Comment