Xcode UIAlertController触点工作不正常
我在UIAlertController中添加了picker视图,但它的触碰并没有作用于整个picker,而只是作用于picker的某些特定部分。请帮我解决这个问题 代码:Xcode UIAlertController触点工作不正常,xcode,ios8,uipickerview,uialertcontroller,Xcode,Ios8,Uipickerview,Uialertcontroller,我在UIAlertController中添加了picker视图,但它的触碰并没有作用于整个picker,而只是作用于picker的某些特定部分。请帮我解决这个问题 代码: if (IS_IOS8_AND_UP) { UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAc
if (IS_IOS8_AND_UP) {
UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
[searchActionSheet.view setBounds:CGRectMake(8, 180, self.viewSize.width, sheetHeight)];
//aView.frame=cgrectmake100100,aView.frame.size.width,aView.frame.size.height
//yourView represent the view that contains UIPickerView and toolbar
[searchActionSheet.view添加子视图:aView];
//[[self-topViewController].view-addSubview:searchActionSheet.view];
[[self-topViewController]presentViewController:searchActionSheet动画:是完成:无]
}
else
{
_actionSheet = [[UIActionSheet alloc] initWithTitle:paddedSheetTitle delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[_actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[_actionSheet addSubview:aView];
[self presentActionSheet:_actionSheet];
_actionSheet.bounds = CGRectMake(0, 0, self.viewSize.width, sheetHeight);
}
见图片
UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil];
[searchActionSheet addAction:alertAction];
[searchActionSheet addAction:alertAction];
[searchActionSheet addAction:alertAction];
[searchActionSheet addSubview:picker];
将alertAction对象添加到alertcontroller,正如我在上面添加的那样。之后,尝试将选择器作为子视图添加到alertcontroller
根据需要添加尽可能多的alertAction对象以调整视图。不知道这是否是正确的方法,但它对我起了作用。UIAlertController的文档说明此类的视图层次结构是私有的,不能修改。