user1673099
user1673099

Reputation: 3289

Dismiss a modal view through popover's table row in iphone SDK

In my app, I presented a modal view. In modal view, I taken a view(Extraview) which contains a table view & a button.

from this button, i open a popview which contains a view(LeftsideView).

-(IBAction)popOverBtnPressed:(id)sender
{
    LeftSideVCViewController *popUp=[[LeftSideVCViewController alloc] initWithNibName:@"LeftSideVCViewController" bundle:nil];



    popView = [[UIPopoverController alloc]initWithContentViewController:popUp];
    popView.delegate =self;

    [popView setPopoverContentSize:CGSizeMake(300, 700)];
    [popView presentPopoverFromRect:CGRectMake(150,30,20,40) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}

enter image description here enter image description here

Now, I want to dismiss modal view on the selection of table row of leftside view. How can i do this.

Upvotes: 1

Views: 508

Answers (3)

user1673099
user1673099

Reputation: 3289

I solved This as follow:

after register for post Notification.

You must have to dismiss the popover first & then dismiss the presented modal view.

-(void)dismissModal:(NSNotification *)notification
{

     [popView dismissPopoverAnimated:YES];
   [self dismissViewControllerAnimated:YES completion:nil];


}

Upvotes: 0

Nitin Gohel
Nitin Gohel

Reputation: 49730

in your Issue Presenting PopOver is a different Class and dismiss Method is a Different Class So you need to Implementing NSNotificationCenter like Bellow:-

add Notification at Your PopOVer Created Class in your ViewDidLoad Method:-

- (void)viewDidLoad
{

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(dismisPopoverInnerPageTeam:)
                                                 name:@"InnerPop"
                                               object:nil];


    [super viewDidLoad];

}

-(void)dismisPopoverInnerPageTeam:(NSNotification *)notification {

    [yourPopOver dismissPopoverAnimated:YES];
}

Now you just need to call this method From your LeftSideVCViewController class UITableView Delegate method didSelectRowAtIndexPath like:-

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"InnerPop" object:self];

}

Hope it's Helps you:)

Upvotes: 2

Vishal
Vishal

Reputation: 8256

Try this:

[popoverController dismissPopoverAnimated:YES];

Upvotes: 0

Related Questions