I'm making app where I use SDCAlertView
(https://github.com/Scott90/SDCAlertView) and its contentView
property in order to display an UITableView
. The problem occurs when I try to scroll through the table.
Here is how I allocate the alert:
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;
This is how I create the table and then add it to the subview of the alert:
//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];
I then add constraints to make the tableview fit in the alert, and then show the alert:
//Make sure the tableview fits in the alert
[soundAlertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[tableHolderView]|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(tableHolderView)]];
[soundAlertView show];
After Doing research, I found that I should probably pass the touches from the contentView
to the contanerView
to the tableView
. While this would work, it requires subclassing and I can't subclass to the access to the contentView
property.
How do I get the tableView
to recognize the touches and scrolls that are recognized by the contentView
of the alert?
Thanks