crazy2431
crazy2431

Reputation: 801

how to display popover click on a tableview cell in ipad

i am using a TableView in my application where i want a Pop over View when i clicked on a tabel cell, all the content which is in table Cell should display in a pop over view so plz suggest me how to do??

i have some sample code below which is not working..so suggest with code i want all the content in the cell to displayed in the pop over view.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIView *aView = [[UIView alloc] init];
UIPopoverController *popoverController = [[UIPopoverController alloc] 
                                          initWithContentViewController:aView];
popoverController.popoverContentSize = CGSizeMake(320, 416);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView 
                 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

Upvotes: 1

Views: 4125

Answers (3)

Tendulkar
Tendulkar

Reputation: 5540

you have to pass the view controller instead of view

Upvotes: -3

Ajeet Pratap Maurya
Ajeet Pratap Maurya

Reputation: 4254

Your code is fine, but You should have UIViewController instead UIView.

Upvotes: 1

visakh7
visakh7

Reputation: 26390

The UIPopoverController class reference clearly states

To display a popover, create an instance of this class and present it using one of the appropriate methods. When initializing an instance of this class, you must provide the view controller that provides the content for the popover. Popovers normally derive their size from the view controller they present

Your popoverController should have a view controller and not a view.

YourViewController *aViewController = [[YourViewController alloc] initWithNibName:nibName bundle:nil];
UIPopoverController *popoverController = [[UIPopoverController alloc] 
                                          initWithContentViewController:aViewController];

Then you can present this pop over

Upvotes: 4

Related Questions