Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView中的表未滚动或接收触摸_Ios_Uitableview_Autolayout_Uitouch_Sdcalertview - Fatal编程技术网

Ios UIView中的表未滚动或接收触摸

Ios UIView中的表未滚动或接收触摸,ios,uitableview,autolayout,uitouch,sdcalertview,Ios,Uitableview,Autolayout,Uitouch,Sdcalertview,我正在制作一个应用程序,使用SDCAlertView()及其contentView属性来显示UITableView。当我尝试在表格中滚动时出现问题 以下是我如何分配警报: SDCAlertView *soundAlertView = [[SDCAlertView alloc] initWithTitle:@"Select Sound" message:@"Select a sound." delegate:self cancelButtonTitle:@"OK" otherButtonT

我正在制作一个应用程序,使用
SDCAlertView
()及其
contentView
属性来显示
UITableView
。当我尝试在表格中滚动时出现问题

以下是我如何分配警报:

    SDCAlertView *soundAlertView = [[SDCAlertView alloc] initWithTitle:@"Select Sound" message:@"Select a sound." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //Give the alert a tag for later id'ing
    soundAlertView.tag = 2;
//Create the tableview controller
    SelectionViewController *soundSelection = [self.storyboard instantiateViewControllerWithIdentifier:@"selectionCont"];

    //assign the table to a local var
    UITableView *table = soundSelection.tableView;
    UIView *tableHolderView = [[UIView alloc] initWithFrame:CGRectMake(table.frame.origin.x, table.frame.origin.y, soundAlertView.contentView.frame.size.width, 200)];

    [tableHolderView addSubview:table];


    //Add the table view to the alert view
    [soundAlertView.contentView addSubview:tableHolderView];
   //Make sure the tableview fits in the alert
    [soundAlertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[tableHolderView]|"
                                                                              options:0
                                                                              metrics:nil
                                                                                views:NSDictionaryOfVariableBindings(tableHolderView)]];
    [soundAlertView show];
以下是创建表并将其添加到警报子视图的方式:

    SDCAlertView *soundAlertView = [[SDCAlertView alloc] initWithTitle:@"Select Sound" message:@"Select a sound." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //Give the alert a tag for later id'ing
    soundAlertView.tag = 2;
//Create the tableview controller
    SelectionViewController *soundSelection = [self.storyboard instantiateViewControllerWithIdentifier:@"selectionCont"];

    //assign the table to a local var
    UITableView *table = soundSelection.tableView;
    UIView *tableHolderView = [[UIView alloc] initWithFrame:CGRectMake(table.frame.origin.x, table.frame.origin.y, soundAlertView.contentView.frame.size.width, 200)];

    [tableHolderView addSubview:table];


    //Add the table view to the alert view
    [soundAlertView.contentView addSubview:tableHolderView];
   //Make sure the tableview fits in the alert
    [soundAlertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[tableHolderView]|"
                                                                              options:0
                                                                              metrics:nil
                                                                                views:NSDictionaryOfVariableBindings(tableHolderView)]];
    [soundAlertView show];
然后添加约束以使tableview适合警报,然后显示警报:

    SDCAlertView *soundAlertView = [[SDCAlertView alloc] initWithTitle:@"Select Sound" message:@"Select a sound." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //Give the alert a tag for later id'ing
    soundAlertView.tag = 2;
//Create the tableview controller
    SelectionViewController *soundSelection = [self.storyboard instantiateViewControllerWithIdentifier:@"selectionCont"];

    //assign the table to a local var
    UITableView *table = soundSelection.tableView;
    UIView *tableHolderView = [[UIView alloc] initWithFrame:CGRectMake(table.frame.origin.x, table.frame.origin.y, soundAlertView.contentView.frame.size.width, 200)];

    [tableHolderView addSubview:table];


    //Add the table view to the alert view
    [soundAlertView.contentView addSubview:tableHolderView];
   //Make sure the tableview fits in the alert
    [soundAlertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[tableHolderView]|"
                                                                              options:0
                                                                              metrics:nil
                                                                                views:NSDictionaryOfVariableBindings(tableHolderView)]];
    [soundAlertView show];
在做了研究之后,我发现我应该将触摸从
contentView
传递到
contanerView
tableView
。虽然这会起作用,但它需要子类化,我不能子类化对
contentView
属性的访问

如何让
tableView
识别警报的
contentView
识别的触摸和滚动


谢谢

我想出来了,诀窍是将
SDCAlertView
本身子类化,然后将
hitTest:
发送到tableview。

设置将UITableView的属性反弹为YES,这对我来说是个问题