2013-08-18 4 views
0

Я делаю приложение, используя панель вкладок. У меня есть 2 вида контроллера: View1 и View2 и RootViewController. В RootViewController.m:Tab Bar в программировании Iphone?

- (void)viewDidLoad 
{ 
    [self.navigationItem setTitle:@"Tab Bar"]; 
    View1 *vc1 = [[View1 alloc]init]; 
    View2 *vc2 = [[View2 alloc]init]; 

    [vc1.tabBarItem setTitle:@"View1"]; 
    [vc2.tabBarItem setTitle:@"View2"]; 

    [self setViewControllers:[NSArray arrayWithObjects:vc1, vc2, nil]]; 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
} 

Когда я строю приложение, у меня есть сообщение об ошибке: Есть белое место. Когда я перехожу к View 2 и обратно в View 1, он исчезает. Я хочу удалить белое место. Пожалуйста, смотрите изображение здесь: http://photo.ssc.vn/images/108Screen_Shot_2013_08_18.jpg Спасибо за помощь!

enter image description here

ответ

0

Это общая проблема при добавлении контроллера просмотра на панели вкладок.

Решение должно установить wantsFullScreenLayout на UINavigationController на NO, поэтому оно даже не попытается оставить этот пробел для строки состояния.

Apple says:

Tab bar controllers support full-screen layout differently from the way most other controllers support it. You can still set the wantsFullScreenLayout property of your custom view controller to YES if you want its view to underlap the status bar or a navigation bar (if present). However, setting this property to YES does not cause the view to underlap the tab bar view. The tab bar controller always resizes your view to prevent it from underlapping the tab bar.

Более подробное объяснение вы можете увидеть это Question.

+0

Огромное спасибо :) – user2678221

+0

@ user2678221: В satckoverflow мы отмечаем, что правый галочку рядом с ответом (Accept the Answer), чтобы сказать «спасибо» :) – Bhavin