我在滚动视图上有一个UIButton。单击该按钮时,将显示操作表。但是按钮会隐藏在工作表后面。我希望按钮向上滚动,以便在动作表上方保持可见状态。 请帮忙
- (IBAction)foodInstructionOrPrescriptionInformationButtonClicked:(UIButton *)sender
{
tagForPicker = sender.tag;
[self presentPicker:sender];
}
- (void)presentPicker:(UIButton*)element
{
actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, 0, 0)];
picker.tag = tagForPicker;
picker.dataSource = self;
picker.delegate = self;
[actionSheet addSubview:picker];
UIToolbar *tools = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
tools.barStyle=UIBarStyleDefault;
[actionSheet addSubview:tools];
UIBarButtonItem *doneButton=[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(btnActionPickerDoneClicked)];
UIBarButtonItem *CancelButton=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(btnActionPickerCancelClicked)];
UIBarButtonItem *flexSpace= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *array = [[NSArray alloc]initWithObjects:CancelButton,flexSpace,flexSpace,doneButton,nil];
[tools setItems:array];
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, self.view.frame.size.width, 400)];
}
else
{
[actionSheet showFromRect:CGRectMake(0, 480, 320, 215) inView:self.view animated:YES];
[actionSheet setBounds:CGRectMake(0, 0, 320, 511)];
}
}
- (void)viewDidLayoutSubviews
{
[backgroundScrollView setContentSize:CGSizeMake(320,1340)];
}