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 01-18-2011, 09:40 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 346
mashercakes is on a distinguished road
Default Dismissing popover with a button

I'm trying to dismiss a popover with a button within the popover. I've tried this:

Code:
MainViewController *m = [[MainViewController alloc] init];
[m.myPopOver dismissPopoverAnimated:YES];
[m release];
However this doesn't work as the popover remains. Is what I'm trying to do even possible?
__________________
PicBoard - a visual support app for children with autism, communication difficulties or learning difficulties. Available now for iPad.

TalkBoard - Adds Communication Aid features to PicBoard, for non-verbal children or adults. Available now for iPad.
mashercakes is offline   Reply With Quote
Old 01-18-2011, 09:53 AM   #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

You made a completely new view controller and dismissed its popover. That doesn't make any sense. You need to dismiss the popover you already have.
__________________
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 01-18-2011, 09:56 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 346
mashercakes is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
You made a completely new view controller and dismissed its popover. That doesn't make any sense. You need to dismiss the popover you already have.
Ok, that makes sense. So how do I reference the popOver which I am trying to dismiss?
__________________
PicBoard - a visual support app for children with autism, communication difficulties or learning difficulties. Available now for iPad.

TalkBoard - Adds Communication Aid features to PicBoard, for non-verbal children or adults. Available now for iPad.
mashercakes is offline   Reply With Quote
Old 01-18-2011, 09:57 AM   #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 have to keep a reference to it. If your view controller already has a myPopOver property, put the popover in there before you show it.
__________________
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 01-18-2011, 10:04 AM   #5 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 346
mashercakes is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
You have to keep a reference to it. If your view controller already has a myPopOver property, put the popover in there before you show it.
MainViewController does have the myPopOver reference, and the popOver is created there ready to be displayed. The problem I'm having is working out how to refer back to it. I've just tried this:

Code:
[[(MainViewController*)self.parentViewController myPopOver] dismissPopoverAnimated: YES];
but again, the popover just stays there.
__________________
PicBoard - a visual support app for children with autism, communication difficulties or learning difficulties. Available now for iPad.

TalkBoard - Adds Communication Aid features to PicBoard, for non-verbal children or adults. Available now for iPad.
mashercakes is offline   Reply With Quote
Old 01-18-2011, 10:06 AM   #6 (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

Ok, you're not providing enough structure here to figure this out.
__________________
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 01-18-2011, 10:16 AM   #7 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 346
mashercakes is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Ok, you're not providing enough structure here to figure this out.
Ok, I have figured this out now but I'll provide some more info for others who may find this post. myPopOver is defined in MainViewController.h:

Code:
//...

@interface MainViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIPopoverControllerDelegate> {
	UIPopoverController *myPopOver;
	//...
}

@property (nonatomic, retain) UIPopoverController *myPopOver;
//...

@end
And gets created in MainViewController.m:

Code:
- (void)viewDidLoad {
	//...
	MyPopOverViewController *rc = [[MyPopOverViewController alloc] init];
	myPopOver = [[UIPopoverController alloc] initWithContentViewController:rc];
	[rc release];
	myPopOver.popoverContentSize = CGSizeMake(254, 95);
	myPopOver.delegate = self;

	//...
I have stopped the popover from automatically dismissing with the following in MainViewController.m:

Code:
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
	return NO;
}
The key to getting the myPopOver to be able to dismiss itself was to give the PopOverController a "parent" property of type MainViewController, then set that to "self" when creating the PopOver in MainViewController. Then the following line dismisses the popOver from within myPopOver.m:

Code:
[parent.myPopOver dismissPopoverAnimated:YES];
__________________
PicBoard - a visual support app for children with autism, communication difficulties or learning difficulties. Available now for iPad.

TalkBoard - Adds Communication Aid features to PicBoard, for non-verbal children or adults. Available now for iPad.
mashercakes is offline   Reply With Quote
Old 11-05-2011, 02:17 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 1
Liefster is on a distinguished road
Default Please Help

Quote:
Originally Posted by mashercakes View Post
Ok, I have figured this out now but I'll provide some more info for others who may find this post. myPopOver is defined in MainViewController.h:

Code:
//...

@interface MainViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIPopoverControllerDelegate> {
	UIPopoverController *myPopOver;
	//...
}

@property (nonatomic, retain) UIPopoverController *myPopOver;
//...

@end
And gets created in MainViewController.m:

Code:
- (void)viewDidLoad {
	//...
	MyPopOverViewController *rc = [[MyPopOverViewController alloc] init];
	myPopOver = [[UIPopoverController alloc] initWithContentViewController:rc];
	[rc release];
	myPopOver.popoverContentSize = CGSizeMake(254, 95);
	myPopOver.delegate = self;

	//...
I have stopped the popover from automatically dismissing with the following in MainViewController.m:

Code:
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
	return NO;
}
The key to getting the myPopOver to be able to dismiss itself was to give the PopOverController a "parent" property of type MainViewController, then set that to "self" when creating the PopOver in MainViewController. Then the following line dismisses the popOver from within myPopOver.m:

Code:
[parent.myPopOver dismissPopoverAnimated:YES];
Hello,

I understand the above statement, but I am new to Objective-C, if it is not to much trouble, can you post the code you used to create the "parent" in each .h and .m file. Thanx in advance.

Liefster ...
Liefster is offline   Reply With Quote
Reply

Bookmarks

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: 363
10 members and 353 guests
7twenty7, blueorb, dre, iAppDeveloper, iGamesDev, Mah6447, Morrisone, mottdog, sacha1996, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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