如何在屏幕顶部放置UIToolbar?

时间:2010-06-09 15:31:41

标签: iphone objective-c xcode

我已经想出如何隐藏导航栏然后显示它内置的工具栏但是工具栏出现在屏幕的底部os我如何将工具栏放在scren的顶部?

这是我的一些代码


        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];



感谢。

1 个答案:

答案 0 :(得分:0)

UIToolbar目前始终位于屏幕底部。我相信这可能会在iOS4中发生变化。

它是UIView的扩展,因此您应该能够手动更改frame属性。但是对于某些控件,比如UIPickerView,这是不受支持的,可能会造成奇怪的视觉故障。

编辑 - 仅供参考UINavigationController的工具栏还会监听它推送的视图控制器的属性,例如“hidesBottomBarWhenPushed”。期望是酒吧位于底部,所以考虑到它是非标准的。

相关问题