2010-06-09 41 views
1

我已經想出瞭如何隱藏導航欄,然後顯示它內置的工具欄,但工具欄出現在屏幕的底部os如何將工具欄放置在scren的頂部?如何將UIToolbar放置在屏幕的頂部?

這裏是我的一些代碼

 

     UIBarButtonItem *yesterday = [[UIBarButtonItem alloc]initWithTitle:@"Yesterday" 
                    style:UIBarButtonItemStyleBordered target:self action:@selector(yesterday:)]; 
    UIBarButtonItem *today = [[UIBarButtonItem alloc]initWithTitle:@"Today" 
                  style:UIBarButtonItemStyleDone target:self action:@selector(today:)]; 
    UIBarButtonItem *tomorrow = [[UIBarButtonItem alloc]initWithTitle:@"Tomorrow" 
                  style:UIBarButtonItemStyleBordered target:self action:@selector(tomorrow:)]; 
    UIBarButtonItem *month = [[UIBarButtonItem alloc]initWithTitle:@"Month" 
                  style:UIBarButtonItemStyleBordered target:self action:@selector(month:)]; 
    NSArray *items = [NSArray arrayWithObjects:yesterday,today,tomorrow,month, nil]; 

    [yesterday release]; 
    [today release]; 
    [tomorrow release]; 
    [month release]; 

    [self setToolbarItems:items]; 


     [[self navigationController] setNavigationBarHidden:YES animated:NO]; 
    [[self navigationController] setToolbarHidden:NO animated:YES]; 


 

感謝。

回答

0

UIToolbar當前總是位於屏幕的底部。我相信這可能會在iOS4中發生變化。

它是UIView的擴展,因此您應該能夠手動更改框架屬性。對於一些控件,像UIPickerView,這是不受支持的,可以創建奇怪的視覺故障。編輯 - 僅供參考UINavigationController的工具欄還會監聽它推送的視圖控制器的屬性,例如「hidesBottomBarWhenPushed」。期望的是,酒吧是在底部,所以考慮到,當它使非標準。

+0

我想通過類似的東西: self.navigationController.toolbar.frame = CGRectMake(0,18,320,45); 但我在頁面底部得到一個空的空間,而不是工具欄現在位於頂端....:S – 2010-06-09 16:59:58

+0

對。這就是我的意思......有很多副作用,很多事情都希望酒吧處於最底層。不幸的是,我認爲你會發現目前只是不支持。 – DougW 2010-06-09 17:49:50

相關問題