While in a tableview where each row contains an accessory button that contains a UIAlertController, I see the following text 3 times each time I touch an accessory button. The text is "Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates." I can eliminate this text if I add the following code: [alert setPreferredContentSize:alert.view.frame.size]; But I do not know if this is the correct thing to do. Could I be eliminating other warnings that are needed? I don't understand why this works, so I hesitate to leave it. But, I am currently investigating a crash in this same code and I don't know if this is involved with the crash or not. Could you possibly direct me to documentation regarding UIAlertController UIAlertControllerStyleActionSheet and UIPopoverPresentationController that address this? Word on the street has it that the properties sourceView and sourceRect are required to be set if the style is ActionSheet. But the street seems to not have a concensus as to the placement of this code. And does any of these factor into the strange warning text I see when this code is activated?
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
... (irrelevant code removed)...
if([item hasDataPopulated]) {
UIAlertAction* clearAction = [UIAlertAction actionWithTitle:@"Clear" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
item.amount = nil;
[wvm save];
[wself.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
[alert addAction:clearAction];
}
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
[wself deleteObjectAtIndexPath:indexPathInDatasource];
}];
[alert addAction:defaultAction];
alert.popoverPresentationController.sourceRect = cell.accessoryView.bounds;
alert.popoverPresentationController.sourceView = cell.accessoryView;
. alert.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown;
[self presentViewController:alert animated:YES completion:nil];
}