I am working on a app, which uses UIPopoverController
, I am getting a problem in presenting that popover, I have a UIView
which is added on self.view, and a tableview added on that view, that table view has a custom cell, which includes a UITextField
, on didBeganEditing
method I need popover to open.
Here is the code:
table = [[UITableView alloc]initWithFrame:CGRectMake(textField.frame.origin.x,textField.frame.origin.y,200,100) style:UITableViewStylePlain];
table.tag=3;
[table setDataSource:self];
[table setDelegate:self];
[table reloadData];
UITableViewController *tableViewController= [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
tableViewController.tableView = table;
popOver= [[UIPopoverController alloc]
initWithContentViewController:tableViewController];
[popOver presentPopoverFromRect:popRect inView:cell permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I will getting following exception
Terminating app due to uncaught exception '
NSInvalidArgumentException
', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]
: Popovers cannot be presented from a view which does not have a window.'