I have a splitView in my app.I have a presented a Modal on click of button from the splitview’s detailview.In that modal I have opened popover which contains splitview’s rootview controller(which contains tableview).
Now I want to dismiss that modal view on didSelect of popover’s tableview.But it does not dismiss.
I have searched a lot for this and tried , but could not get any solution.
My Tried code is as follow:
//DetailView (Presented ModalView).m
-(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,5,20,40) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dismissModal
{
[self dismissViewControllerAnimated:YES completion:nil];
}
// LeftSideView.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailView *d=[[DetailView alloc]init];
[d dismissModal];
}
// GridView.m
Presenting DetailView from a view (GridView)
-(IBAction)Grid_buttonPressed:(id)sender {
DetailView *rd=[[DetailView alloc]initWithNibName:@"DetailView" bundle:nil];
rd.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:rd animated:YES];
}
How to do this ?
Thanks.
By writing
DetailView *d=[[DetailView alloc]init]u instantiate another instance of DetailView.The way out in this situation would be creating a delegate for LeftSideView
Somewhere above:
And then: