user1673099
user1673099

Reputation: 3289

Push a View from popOver in ipad

I open a popOver with a view(DetailView) in a view(MapView). it works fine.

But in my detail view has a button(feedback).so i want to push the another view(feedbackform)on btton clicked.

I tried but nothing is Happened.

Can i push the view inside the popover?

My code is as follow:

// MapView.m

detailsView *popUp=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];


        popView = [[UIPopoverController alloc]initWithContentViewController:popUp];

        popView.delegate =self;

        [popView setPopoverContentSize:CGSizeMake(600, 500)];

 [popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}  


//Detailview.m

-(IBAction)openFeedbackForm:(id)sender {

fbView = [[deatailsFeedback alloc]
                  initWithNibName:@"deatailsFeedback_ipad" bundle:nil];
 [self.navigationController pushViewController:fbView animated:YES];
}

Upvotes: 1

Views: 1889

Answers (2)

perrohunter
perrohunter

Reputation: 3526

To achieve this your detailsView should be a Navigation controller with a root controller to the original detailsView.

This way when you pop the navigationController, you can perform push from your detailsView and that would only affect the popOver view

    detailsView *popUpView=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];

    UINavigationController *popUpNavController = [[UINavigationController alloc] initWithRootViewController:popUpView];    

    popView = [[UIPopoverController alloc]initWithContentViewController:popUpNavController];

    popView.delegate =self;

    [popView setPopoverContentSize:CGSizeMake(600, 500)];

    [popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}


//Detailview.m

-(IBAction)openFeedbackForm:(id)sender {

    fbView = [[deatailsFeedback alloc]
              initWithNibName:@"deatailsFeedback_ipad" bundle:nil];
    [self.navigationController pushViewController:fbView animated:YES];
}

Upvotes: 1

hishamaus
hishamaus

Reputation: 183

If I understand your code correctly, openFeedForm IBAction method is in Detailview.m? Meaning the first part of the code is in a different class than the one at the bottom?

If so, since Detailview itself is not in a navigationController, it will not push anything to its non-existant navigation controller.

What you want to do is have MapView push the new view in its navigationController.

Side note: since you are setting the delegate of the popUp in MapView as (self) the IBAction method should be defined in MapView

(This is assuming my first statement about understanding your code is correct)

Upvotes: 0

Related Questions