Loading a new UIView over the rootUIView on UIButton click from UIPopovercontroller?

You'll need to have the root view controller first dismiss the popover when the button is pressed in the popover and then you can present the new view from the root view controller.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

My application is very simple and I am not using the splitview controller. My question is .. how can I load a new uiview over my root view controller on UIButton click from a popovercontroller view. Ipad uipopovercontroller link|improve this question asked Feb 9 '11 at 15:19Meeya134 88% accept rate.

You'll need to have the root view controller first dismiss the popover when the button is pressed in the popover and then you can present the new view from the root view controller. For details on how to do the dismissal of the popover using a button inside the popver, see my previous answer "How to setup Popover views to dismiss properly". The main idea is: To dismiss the popover manually, you'll need to keep a reference to it.

A good place would be in the view controller that shows the popover. To have the button inside the content view controller tell the original view controller (that presented the popover) to dismiss the popover, two of the possible ways are delegate+protocol or NSNotificationCenter. In that previous answer, PresenterViewController is your root view controller (the one that presents the popover).

The difference in your case will be in the contentFooViewControllerDone method (which you would put in your root view controller): - (void)contentFooViewControllerDone:(NSNotification *)notification { // Button in content view controller was tapped, dismiss popover... self. PopoverController dismissPopoverAnimated:YES; // Load new view here... // Note: If intending to use presentModalViewController // (instead of addSubView), you might need to set animated to NO // for above popover dismissal (otherwise presentModal will do nothing) // or use performSelector:withObject:afterDelay to present new // view controller to animate both dismiss and present. }.

ABitObvious, But I need a button action code to load a uiview over my rootViewController. – Meeya Feb 9 '11 at 16:21 You are presenting a popover controller from the root view controller, right? In the content view controller, you have a button?

Did you create the button in IB or programmatically? Not sure what you are asking by "need a button action code". What have you got so far?

– Anna Karenina Feb 9 '11 at 16:34 @aBitObvious, yes correct ..and that popover has a UIButton which is created in interface builder. And when I click on the button I need to open a new uiview over my root view. I tried to run the pushviewcontroller code on it.

But no success. – Meeya Feb 9 '11 at 18:39 That's what this answer and the previous linked answer shows how to do. You need to first dismiss the popover and then push from the root view controller (not in the button action method).

Try following the steps in the previous linked answer and this one. – Anna Karenina Feb 9 '11 at 18:45 You would put the pushViewController call in the contentFooViewControllerDone method shown above (which goes in your root view controller). – Anna Karenina Feb 9 '11 at 18:48.

NSNotificationCenter defaultCenter addObserver:self selector:@selector(contentFooViewControllerDone:) name:@"contentFooViewControllerDone" object:popoverController. ContentViewController; - (void)contentFooViewControllerDone:(NSNotification *)notification { // Button in content view controller was tapped, dismiss popover... self. PopoverController dismissPopoverAnimated:YES; } - (void)dealloc { //stop listening for notifications and release popoverController... NSNotificationCenter defaultCenter removeObserver:self; popoverController release; super dealloc; } - (IBAction)dismissButtonTapped { NSNotificationCenter defaultCenter postNotificationName:@"contentFooViewControllerDone" object:self; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions