0

我在标签栏控制器中添加了一些视图控制器,并在视图控制器中添加了 1 个文本字段,因此当我单击文本字段时,我调用 UIactionsheet。操作表包含 2 个子部分(1. UIpickerview 2. UItoolbar)...我遇到了一些问题,例如当我加载 UIactionsheet 时它工作正常,但我无法选择任何行.. 或者不单击完成按钮以关闭操作表。我在这里放了一些代码..

在 tabbarcontroller.m

-(void)LoadActionSheet
{
    actionsheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    actionsheet.actionSheetStyle = UIActionSheetStyleDefault;
    actionsheet.delegate = self;

}

in viewcontroller.m

-(void) Comboaction:(NSMutableArray *)DataArray     
{


  EditTabController *obj_tab = [[EditTabController alloc] init];
  [obj_tab LoadActionSheet];

  UIToolbar *Toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(100, obj_tab.actionsheet.frame.origin.y-15, 200, 44)];
  Toolbar.barStyle = UIBarStyleBlack;
  [Toolbar sizeToFit];
  [Toolbar bringSubviewToFront:obj_tab.actionsheet];


  NSMutableArray *barItems = [[NSMutableArray alloc] init];

  UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
  [barItems addObject:flexSpace];

  UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(DissmissPickerview)];
  [barItems addObject:doneBtn];
  [Toolbar setItems:barItems animated:YES];



  [obj_tab.actionsheet setBounds:CGRectMake(0, obj_tab.tbar.frame.origin.y-100, 325,40)];

  picker = [[UIPickerView alloc] init];
  [picker setFrame:CGRectZero];
  picker.tag = 101;
  picker.delegate = self;
  picker.dataSource = self;
  picker.showsSelection

  Indicator = YES;
    [picker setShowsSelectionIndicator:YES];
    [picker setBackgroundColor:[UIColor blackColor]];
   // [picker setFrame:CGRectMake(0,Toolbar.frame.size.height+1, 320, 360)]; 

    [picker bringSubviewToFront:obj_tab.actionsheet];  
    [obj_tab.actionsheet setDelegate:self];
    [obj_tab.actionsheet addSubview:Toolbar];

   [obj_tab.actionsheet addSubview:picker];
   [obj_tab.actionsheet setBounds:CGRectMake(0, 0, 320, 50)];


   [obj_tab.actionsheet showInView:[UIApplication sharedApplication].keyWindow];


}

和所有pickerview委托方法..它在简单的视图控制器中工作正常。但在 tabbarcontroller 中无法正常工作..

4

0 回答 0