嘿,所以我有一个问题,我将操作表插入到另一个视图控制器的滚动视图内部的视图中。动作表工作得很好,问题是如果我在滚动视图中完全下降,动作表就会被剪掉。我已经尝试了几种解决方案,但都没有运气。我认为问题在于操作表被插入到放置在滚动视图内的视图中。任何人都知道如何从滚动视图所在的视图控制器启动操作表?这是我现在正在尝试的方法:
当一个按钮被触摸时,它会调用这个方法:
- (IBAction)callDP:(id)sender {
UIButton *selectedButton = (UIButton *)sender;
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
datePickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame];
datePickerView.tag = 10;
[datePickerView addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:datePickerView];
[actionSheet setTitle:@"Start Date"];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
datePickerView.datePickerMode = UIDatePickerModeDate;
//THIS IS THE PART THAT I THINK I AM HAVING THE PROBLEM WITH
// [actionSheet showFromToolbar:self.toolbarItems];
//[actionSheet showFromTabBar:self.parentViewController.tabBarController.tabBar];
[actionSheet showInView:self.parentViewController.view];
}
这是我将视图插入滚动视图的地方。我已经设置好了,以便我使用来自不同 uiviewcontroller 类的视图来控制一切。我这样做的原因是我可以拥有可滚动的部分,但能够直观地创建我需要的一切,而不必以编程方式进行......如果这有点令人困惑,我深表歉意。我可以澄清是否需要......但在这里。包含我要放入滚动视图的视图的视图控制器类称为注册页面。它在registrationPage 内部调用actionSheet。让我知道你的想法...
registrationPage = [[RegistrationPageToInsertViewController alloc]init];
viewToInsert = registrationPage.view;
[scrollView addSubview:viewToInsert];
[scrollView setContentSize:viewToInsert.frame.size];
// [scrollView sendSubviewToBack:imgView];
//scrollView.contentSize=CGSizeMake(320,416);
[self.view bringSubviewToFront:scrollView];
以下是一些屏幕截图,可帮助您了解我在说什么: