隐藏的导航栏导致操作表出现问题

时间:2012-09-04 00:44:26

标签: objective-c ios uinavigationcontroller uinavigationbar uiactionsheet

enter image description here

我的uinavigationbarcontroller中的导航栏是隐藏的,但我的动作表认为它仍然存在,因此在动作页面顶部给我一个亮点(如上所示)。如何删除此/欺骗我的动作表以认为它是正常的uiimageview?

导航栏在didLoad中隐藏起来:

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

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (![self.navigationController isNavigationBarHidden])
    {
        [self.navigationController setNavigationBarHidden:YES animated:animated];
    }
}

动作表在didLoad中显示如下:

actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];

UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 200,320,16)];
[pickerToolbar sizeToFit];
    pickerToolbar.barStyle = UIBarStyleBlackTranslucent;

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

    UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonSystemItemCancel target:self action:@selector(cancel_clicked:)];
    [barItems addObject:cancelBtn];

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

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done_clicked:)];

    [barItems addObject:doneBtn];
    [pickerToolbar setItems:barItems animated:YES];
    [actionSheet addSubview:pickerToolbar];

UIPickerView *locationPicker = [[UIPickerView alloc] init];
locationPicker.frame = CGRectMake(0, 244, 320, 216);
locationPicker.delegate  = self;
locationPicker.dataSource = self;
locationPicker.showsSelectionIndicator = YES;
locationPicker.tag = 1;
[actionSheet addSubview:locationPicker];

然后它在文本字段触摸动画。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField == locationTextField.self)
    {
        [actionSheet showInView:self.view];
        [actionSheet setFrame:CGRectMake(0, 0, 320, 480)];
        [nameField resignFirstResponder];
    }
}

1 个答案:

答案 0 :(得分:1)

我认为问题在于您选择显示操作表的视图。尝试在应用的主窗口中显示它。