iphone - Why don't my TabBar buttons autoresize on the iPad? -
i'm building universal ios app , ipad version uses splitviewcontroller. in popover view, have uitabbarcontroller 2 buttons. when runs on iphone, tabbar buttons correctly stretch fill entire width of view...
...but on ipad, in popover view, buttons don't stretch fill entire width...
i'm creating uitabbarcontroller programmatically...
inspectiontabbarviewcontroller *inspectiontabbarvc; inspectionlistviewcontroller *inspectionlistvc; self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) { inspectionlistvc = [[inspectionlistviewcontroller alloc] initwithsunday:no]; inspectionlistvc.managedobjectcontext = self.managedobjectcontext; uinavigationcontroller *calendarnavvc = [[uinavigationcontroller alloc] initwithrootviewcontroller:inspectionlistvc]; calendarnavvc.title = @"calendar"; inspectionmapviewcontroller *mapviewvc = [[inspectionmapviewcontroller alloc] initwithnibname:@"inspectionmapview_iphone" bundle:nil]; uinavigationcontroller *mapdnavvc = [[uinavigationcontroller alloc] initwithrootviewcontroller:mapviewvc]; mapdnavvc.title = @"map"; inspectiontabbarvc = [[inspectiontabbarviewcontroller alloc] init]; [inspectiontabbarvc addchildviewcontroller:calendarnavvc]; [inspectiontabbarvc addchildviewcontroller:mapdnavvc]; self.window.rootviewcontroller = inspectiontabbarvc; } else { inspectionlistvc = [[inspectionlistviewcontroller alloc] initwithsunday:no]; uinavigationcontroller *calendarnavvc = [[uinavigationcontroller alloc] initwithrootviewcontroller:inspectionlistvc]; calendarnavvc.title = @"calendar"; inspectionmapviewcontroller *mapviewvc = [[inspectionmapviewcontroller alloc] initwithnibname:@"inspectionmapview_ipad" bundle:nil]; uinavigationcontroller *mapdnavvc = [[uinavigationcontroller alloc] initwithrootviewcontroller:mapviewvc]; mapdnavvc.title = @"map"; inspectiontabbarvc = [[inspectiontabbarviewcontroller alloc] init]; [inspectiontabbarvc addchildviewcontroller:calendarnavvc]; [inspectiontabbarvc addchildviewcontroller:mapdnavvc]; detailviewcontroller *detailviewcontroller = [[detailviewcontroller alloc] initwithnibname:@"detailviewcontroller_ipad" bundle:nil]; uinavigationcontroller *detailnavigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:detailviewcontroller]; self.splitviewcontroller = [[uisplitviewcontroller alloc] init]; self.splitviewcontroller.delegate = detailviewcontroller; self.splitviewcontroller.viewcontrollers = [nsarray arraywithobjects:inspectiontabbarvc, detailnavigationcontroller, nil]; self.window.rootviewcontroller = self.splitviewcontroller; inspectionlistvc.detailviewcontroller = detailviewcontroller; inspectionlistvc.managedobjectcontext = self.managedobjectcontext; detailviewcontroller.detailviewcontrollerdelegate = inspectionlistvc; } [self.window makekeyandvisible];
i tried setting autoresizemask inside inspectiontabbarviewcontroller's loadview method using following statement...
self.tabbar.autoresizingmask = uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin | uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexiblewidth;
...but didn't work either. how can uitabbar buttons fill entire width of of view?
thanks in advance help!
change uitabbar
property itempositioning
uitabbaritempositioningfill
:
self.tabbar.itempositioning = uitabbaritempositioningfill;
swift version:
tabbar.itempositioning = .fill
Comments
Post a Comment