Trying to dismiss a popover view controller with a table view inside of it

108 views Asked by At

I'm trying to dismiss a popover when selecting a cell inside of it. I have created a custom delegate to support this however it is not working: In my class that houses the PopOver and table View I have the following:

In .h:

@protocol DismissDelegate <NSObject>

-(void)didTap;

@end


@interface AssistanceNeededAtPopOverViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>


@property (nonatomic, assign) id <DismissDelegate> delegate;

In .m:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   
    [self.delegate didTap];
}

In .h of the viewcontroller where the popover lives in:

@interface GlobalPageSideDetailViewController : BaseViewController <UITextFieldDelegate, UIAlertViewDelegate,UIPopoverControllerDelegate,DismissDelegate>

and in .m:

AssistanceNeededAtPopOverViewController *classpop = [[AssistanceNeededAtPopOverViewController alloc]init];
classpop.delegate = self;


-(void)didTap{
    if (self.assistanceNeededAtPopover != nil) {
        [self.assistanceNeededAtPopover dismissPopoverAnimated:YES ];
        self.assistanceNeededAtPopover = nil;
    }
}

this should be read and the popover should be dismissed...any help would be appreciated...

1

There are 1 answers

0
GaétanZ On BEST ANSWER

You have to set the delegate of your AssistanceNeededAtPopOverViewController that pops the controllerview, as the new GlobalPageSideDetailViewController.

Here you're setting the delegate of a controller you just instantiate and not the one which poped the controller.