我正在製作應用程序,我使用SDCAlertView
(https://github.com/Scott90/SDCAlertView)及其contentView
屬性以顯示UITableView
。當我嘗試滾動表格時發生問題。UIView內部表格不滾動或接收觸摸
這裏是我如何分配警報:
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
識別的觸摸和滾動?
感謝