Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-27-2010, 01:19 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 3
mdschm2 is on a distinguished road
Question Popover Dismissal

Hello everyone, I know there are dozens of threads on accomplishing this, but I've tried them all and must be overlooking something stupid.

I have two ViewControllers, a main view controller and a popover view controller. The main controller is the delegate to the popover, and the popover view controller manages the content of the popover. I have it setup so that if a User selects a row in a table displayed in the popover, a method is called in the main controller. I know this portion is working fine. Now I need to determine what to call in order to dismiss the popover once the user selects an item in the table.

This is the Popover Code in the Main Controller:

Code:
-(IBAction)popOverViewCall:(id)sender{
	PopOverViewController *myViewControllerForPopover = [[PopOverViewController alloc] initWithNibName:@"PopOverView" bundle:nil ];
	UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:myViewControllerForPopover];
	self.popoverController = popover;
	popoverController.delegate = self;
	
	[popover release];
	[myViewControllerForPopover release];
	
	CGPoint point = {20,45}; // Place to put on screen
	CGSize size = {120,45}; // A content range (see apple docs)
	[popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height)
									   inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

-(void) dismissPopover {
	NSLog(@"Inside Dismiss Method");
	[popoverController dismissPopoverAnimated:NO];
}
And this is the portion of the Popover View controller that executes after the user touches a row in the table:
Code:
	MainViewController *myController = [[MainViewController alloc] init];
	[myController dismissPopover];
The dismissPopover method is called when the user clicks, but I can't get the darn popover to go away.

Any hints?
mdschm2 is offline   Reply With Quote
Old 07-27-2010, 01:27 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
MainViewController *myController = [[MainViewController alloc] init];
[myController dismissPopover];
This creates a new view controller. You want a reference to your existing view controller.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-27-2010, 01:54 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 3
mdschm2 is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Code:
MainViewController *myController = [[MainViewController alloc] init];
[myController dismissPopover];
This creates a new view controller. You want a reference to your existing view controller.
Thanks BrianSlick, so I'm effectively creating a new instance of the View Controller and trying to release a popover that hasn't been created yet. Could you elaborate on how I could reference the already created View Controller?
mdschm2 is offline   Reply With Quote
Old 07-27-2010, 02:59 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You could create a delegate property in your detail view controller. Assign the main view controller to that, so you can talk to it from the detail view controller.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
development, popover

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 346
14 members and 332 guests
alexP, appservice, bignoggins, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:44 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0