I am using a UIButton, on clicking it I want to display the contents that are present in my NSMutableArray in UITableView with the help of UIPopOverController i.e. I want a UITableView to pop up whose cells show the contents of my NSMutableArray.
I am using the following lines of code:
UITableViewController *table= [[UITableViewController alloc]init];
table.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:table];
self.popoverController = popover;
popoverController.delegate = self;
NSString *hDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *hFilePath = [hisDir stringByAppendingPathComponent:@"hhhh.txt"];
NSArray *array = [NSArray arrayWithContentsOfFile:hFilePath ];
NSMutableArray *kkkk = [[NSMutableArray alloc] init];
for (NSDictionary *dict in array) {
[kkkk addObjectsFromArray:[dict allKeys]];
}
table = [[UIImageView alloc] initWithFrame:[window bounds]];
// Set up the image view and add it to the view but make it hidden
[window addSubview:table];
table.hidden = YES;
[window makeKeyAndVisible];
I am unable to get the UITableView to pop up on the press of my UIButton. Can anyone help me to sort it out?
One way to show the
UITableViewin theUIPopOverControlleris by creating a newUIViewControllerclass. And invoking it ininitWithContentViewControllermethod ofUIPopOverController.1. Create a new
UIViewControllerorUITableViewControllerclass. Create an instance of it.2. Use the instance in the
initWithContentViewControllermethod ofUIPopOverController.3. Mention from where it should “pop”
For Example in your
Buttonaction :It seems you want to present it from a
UIBarButtonItemso instead ofpresentPopoverFromRectusepresentPopoverFromBarButtonItem