ios - Xcode Override Storyboard Layout -
quick question, looked everywhere answer no avail. have stroyboard loads tabviewcontroller initial view. first tab autoselected , loaded (which want). have customized layout of view programatically. has 1 uiimage , 6 uibuttons. adjusted proprotionately in code. when viewcontroller loads not apply programatic formatting. if leave tab or select button , return viewcontroller correct formatting is there. don't why doesn't load programmed formatting begin with. have formatting initialized in viewdidload calling function still loads storyboard layout. please advise.
thanky
- (void)viewdidload { [super viewdidload]; [self supportedinterfaceorientations]; [self orientationadjust]; nslog(@"[info] %@ loaded",self); [[nsnotificationcenter defaultcenter] addobserver: self selector: @selector(orientationadjust:) name: uiapplicationdidchangestatusbarorientationnotification object: nil]; } -(void)orientationadjust { navheight = self.navigationcontroller.navigationbar.frame.size.height; tabbarheight = self.tabbarcontroller.tabbar.frame.size.height; statusbarsize = [[uiapplication sharedapplication] statusbarframe]; screen = [[uiscreen mainscreen] bounds]; screenheight = cgrectgetheight(screen); screenwidth = cgrectgetwidth(screen); screencenter = cgrectgetmidx(screen); orientation = [[uidevice currentdevice] orientation]; if (uideviceorientationislandscape(orientation)) { halfscreen = screenheight / 2; statusbarheight = cgrectgetwidth(statusbarsize); banner.frame = cgrectmake(0, statusbarheight + navheight - 10, screenheight, screenwidth / 3.5); bannerheight = cgrectgetheight(banner.frame); bannerwidth = cgrectgetwidth(banner.frame); btnkits.frame = cgrectmake(halfscreen - (screenheight / 2.5), navheight + statusbarheight + bannerheight - 10, screenheight / 2.5, screenwidth / 8); btnfusers.frame = cgrectmake(halfscreen - (screenheight / 2.5), navheight + statusbarheight + bannerheight + screenwidth / 8 - 10, screenheight / 2.5, screenwidth / 8); btnkitid.frame = cgrectmake(halfscreen - (screenheight / 2.5), navheight + statusbarheight + bannerheight + screenwidth / 4 - 10, screenheight / 2.5, screenwidth / 8); btntips.frame = cgrectmake(halfscreen , navheight + statusbarheight + bannerheight - 10, screenheight / 2.5, screenwidth / 8); btnresets.frame = cgrectmake(halfscreen , navheight + statusbarheight + bannerheight + screenwidth / 8 - 10, screenheight / 2.5, screenwidth / 8); btnexit.frame = cgrectmake(halfscreen , navheight + statusbarheight + bannerheight + screenwidth / 4 - 10, screenheight / 2.5, screenwidth / 8); [self settextsize]; } else if (uideviceorientationisportrait(orientation)) { statusbarheight = cgrectgetheight(statusbarsize); halfscreen = cgrectgetwidth(screen) / 2; banner.frame = cgrectmake(0, statusbarheight + navheight + 10, screenwidth, screenheight / 8); bannerheight = cgrectgetheight(banner.frame); bannerwidth = cgrectgetwidth(banner.frame); cgfloat btnheight = (screenheight - tabbarheight - bannerheight) / 8; btnkits.frame = cgrectmake(halfscreen - (screenwidth/2.5), navheight + statusbarheight + bannerheight + 10, screenwidth *.75, btnheight); btnfusers.frame = cgrectmake(halfscreen - (screenwidth/2.5), navheight + statusbarheight + bannerheight + btnheight + 10, screenwidth *.75, btnheight); btnkitid.frame = cgrectmake(halfscreen - (screenwidth/2.5), navheight + statusbarheight + bannerheight + (btnheight * 2) + 10, screenwidth *.75, btnheight); btntips.frame = cgrectmake(halfscreen - (screenwidth/2.5), navheight + statusbarheight + bannerheight + (btnheight * 3) + 10, screenwidth *.75, btnheight); btnresets.frame = cgrectmake(halfscreen - (screenwidth/2.5), navheight + statusbarheight + bannerheight + (btnheight * 4) + 10, screenwidth *.75, btnheight); btnexit.frame = cgrectmake(halfscreen- (screenwidth/2.5), navheight + statusbarheight + bannerheight + (btnheight * 5) + 10, screenwidth *.75, btnheight); [self settextsize]; } }
okay figured out problem. when compiler steps orientationadjust value of orientation upon initial build uideviceorientationunknown added
else if (orientation == uideviceorientationunknown)
condition formatting want. loaded view needed.
thanks looking me.
Comments
Post a Comment