views:

24

answers:

1

I've figured out how to hide the navigation bar and then show the toolbar it has built-in but the toolbar appears at the bottom os the screen how can i position the toolbar on the top of the scren?

here's some of my code


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



Thanks.

A: 

UIToolbar's are currently always positioned at the bottom of the screen. I believe this may change in iOS4.

It's an extension of UIView, so you should be capable of manually changing the frame property. For some controls though, like UIPickerView, this is unsupported and can create bizarre visual glitches.

EDIT - FYI the UINavigationController's toolbar also listens to properties of the view controllers it pushes, such as "hidesBottomBarWhenPushed". The expectation is that the bar is on the bottom, so consider that when making it non-standard.

DougW
i figured it out with something like:self.navigationController.toolbar.frame=CGRectMake(0, 18, 320, 45);but i get an empty space at the bottom of the page instead the toolbar is located now at the top.... :S
Mr_Nizzle
Right. That's what I meant... there's a lot of side effects, and a lot of things expect that bar to be at the bottom. I think you'll find it's just not supported at this time unfortunately.
DougW