2016-07-23 2 views
0

Я новичок в объекте c.I создаю UITabbar программно в AppleDelegate, и я хочу изменить ширину панели вкладок. Мой код выглядит так:Как изменить ширину UITabbar и добавить scrollview в нее в объекте c

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds ]]; 
     NewsScreen *news=[[NewsScreen alloc]initWithNibName:@"NewsScreen" bundle:nil ]; 
     MenuScreen *menu =[[MenuScreen alloc] initWithNibName:@"MenuScreen" bundle:nil]; 
     EmergencyScreen *emergency =[[EmergencyScreen alloc]initWithNibName:@"EmergencyScreen" bundle:nil ]; 
     NewsScreen *NewS = [[NewsScreen alloc] initWithNibName:@"NewsScreen" bundle:nil]; 
     CalenderScreen *calender=[[CalenderScreen alloc]initWithNibName:@"CalenderScreen" bundle:nil ]; 
     NotificationScreen *notification =[[NotificationScreen alloc] initWithNibName:@"NotificationScreen" bundle:nil]; 
     HelpScreen *help =[[HelpScreen alloc] initWithNibName:@"HelpScreen" bundle:nil]; 
     UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:menu]; 
     UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:emergency]; 
     UINavigationController *nav3=[[UINavigationController alloc]initWithRootViewController:NewS]; 
     UINavigationController *nav4=[[UINavigationController alloc]initWithRootViewController:calender]; 
     UINavigationController *nav5=[[UINavigationController alloc]initWithRootViewController:notification]; 
     UINavigationController *nav6=[[UINavigationController alloc]initWithRootViewController:help]; 
     nav=[[UINavigationController alloc]initWithRootViewController:news ]; 
     tab=[[UITabBarController alloc]init]; 
     tab.viewControllers=[[NSArray alloc]initWithObjects:nav1,nav2,nav3,nav4,nav5,nav6, nil]; 
     UITabBarItem *tabItem = [[[tab tabBar] items] objectAtIndex:0]; 
     [tabItem setTitle:@"Menu"]; 
     tabItem.image=[UIImage imageNamed:@"Menu.png"]; 
     UITabBarItem *tabItem1 = [[[tab tabBar] items] objectAtIndex:1]; 
     [tabItem1 setTitle:@"Emergency"]; 
     tabItem1.image=[UIImage imageNamed:@"Emergency.png"]; 
     UITabBarItem *tabItem2 = [[[tab tabBar] items] objectAtIndex:2]; 
     [tabItem2 setTitle:@"News"]; 
     tabItem2.image=[UIImage imageNamed:@"News.png"]; 
     UITabBarItem *tabItem3 = [[[tab tabBar] items] objectAtIndex:3]; 
     [tabItem3 setTitle:@"Calender"]; 
     tabItem3.image=[UIImage imageNamed:@"Calender.png"]; 
     UITabBarItem *tabItem4 = [[[tab tabBar] items] objectAtIndex:4]; 
     [tabItem4 setTitle:@"Help"]; 
     tabItem4.image=[UIImage imageNamed:@"Help.png"]; 
    self.window.rootViewController=nav; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

и в другой кнопке viewcontroller Нажмите «Я делаю вот так».

AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; 
     [appDelegate.window setRootViewController:appDelegate.tab]; 

Но это не показывает мне четвертый пункт. Вместо этого он показывает мне больше. Я просто хочу показать элемент и добавить в него прокрутку. Заранее спасибо.

ответ

0

Вы используете панель вкладок по умолчанию, поэтому она показывает вам больше возможностей. Если вы хотите настроить его, создайте собственную панель вкладок, чтобы вы могли изменить ее в зависимости от того, какой вы хотите. Спасибо.