工具栏上方的子视图

时间:2011-05-03 07:31:20

标签: iphone ipad

我使用[self setToolbarItems:items];添加按钮到工具栏我想显示子视图首先甚至是工具栏我使用下面的代码,但它在工具栏后面

任何建议如何在上面进行

 pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,744, 768, 216)];
        mytab = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 700, 768, 44)];


    pickerView.alpha=0.0;
    mytab.alpha=0.0;


    pickerView.showsSelectionIndicator = YES;
    pickerView.dataSource = self;
    pickerView.delegate = self;

    [self.view addSubview:pickerView];
    [self.view bringSubviewToFront:pickerView]; 


    mytab.tintColor=[UIColor blackColor];

    UIBarButtonItem * bt1=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(_cancel)];
    UIBarButtonItem * flx=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

    NSArray *arr=[[NSArray alloc] initWithObjects:flx,bt1,nil];
    [mytab setItems:arr];
    [self.view addSubview:mytab];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    pickerView.alpha=1.0;
    mytab.alpha=1.0;
    [UIView commitAnimations];


    [pickerView release];
    [mytab release];
    [bt1 release];
    [flx release];
    [arr release];

2 个答案:

答案 0 :(得分:0)

您正在选择器后添加工具栏...添加工具栏拳头然后选择器...

实际上我认为你应该将选择器呈现为模态视图控制器的视图..

编辑:

您可以在appple的示例代码中看到模态视图控制器的显示方式。寻找presentModalViewController方法

SimpleEKDemo

Metronome

答案 1 :(得分:0)

我只是从pickerview和工具栏的Y中减去44