我的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];
然后在textfield touch上对其进行动画处理。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField == locationTextField.self)
{
[actionSheet showInView:self.view];
[actionSheet setFrame:CGRectMake(0, 0, 320, 480)];
[nameField resignFirstResponder];
}
}
最佳答案
我认为问题在于您选择显示操作表的视图。尝试在应用程序的主窗口中显示它。