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 02-08-2012, 08:20 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 38
cthesky is on a distinguished road
Default Show the Pop Over while previous Pop Over still visible cause apps crash?

Hi all,

In my project, when I clicked a Bar Button, a pop over will be displayed, but when I clicked that Bar Button again while the previous pop over still visible, it cause the application crash. Below is my code that show the pop over when click on Bar Button:

Code:
-(IBAction) showPopOver:(id) sender
{      
        PopOverViewController *popOver = [[PopOverViewController alloc]     
        initWithNibName:@"PopOverViewController" bundle:[NSBundle 
        mainBundle]]; 
        
        UIPopoverController * myPopOver = [[UIPopoverController alloc]   
        initWithContentViewController:popOver]; 
        
        myPopOver.delegate = self;
        [popOver release];
        
        self.popOverController = myPopOver;
        [myPopOver release];
        
        [self.popOverController presentPopoverFromBarButtonItem:sender 
        permittedArrowDirections:UIPopoverArrowDirectionAny 
        animated:YES];    
}
After I do some survey, I found that may be I need to do some checking using isPopoverVisible property when need display pop over. But I hope I can find out why my application crashed just now? Anyone know what cause the above case occur?

Any comments and ideas are welcome and appreciated. Thanks a lot.
cthesky is offline   Reply With Quote
Old 02-08-2012, 08:36 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

What is the crash message in the console?
__________________
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 02-08-2012, 08:54 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Illinois
Posts: 44
GHuebner is on a distinguished road
Default

I thought the Apple interface guidelines noted that if a popover was being displayed already that pressing the bar button should do Nothing. This is what you should probably code for.

So if the popover controller is nil, then create it. Otherwise do nothing.


Quote:
Originally Posted by BrianSlick View Post
What is the crash message in the console?
GHuebner is offline   Reply With Quote
Old 02-08-2012, 08:57 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 38
cthesky is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
What is the crash message in the console?
Hi,

In the console not have crash message. What happened is in the console there state "sharedlibrary apply-load-rules all (gdb) " and then in XCode, it jumps to the code inside main.m and display a message " Thread 1: Problem received signal: "SIGABRT". "

Do you have any idea on this issue?

Thanks for your reply.
cthesky is offline   Reply With Quote
Old 02-08-2012, 09:23 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 38
cthesky is on a distinguished road
Default

Quote:
Originally Posted by GHuebner View Post
I thought the Apple interface guidelines noted that if a popover was being displayed already that pressing the bar button should do Nothing. This is what you should probably code for.

So if the popover controller is nil, then create it. Otherwise do nothing.
Hi,

Yes, at first I also display pop over by checking whether the pop over is nil. So, at that time I reset the popover controller back to nil inside popoverControllerDidDismissPopover method. But I have two bar buttons that used to pop up two different pop over controller in same interface. So, I face a problem in a case below:

- When I click both bar buttons, both pop overs will be displayed.
- Then, when I clicked outside the pop over views to dismiss the pop over, both pop over controllers set back to nil but what happens in interface is it just dismiss one of the pop overs.
- So, when I click the bar button again ( the bar button with the pop over still visible), since its pop over controller is set to nil already, it recreate and represent it and cause my app crash. But this time the crash message become "Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.".


So, when I display the pop overs by checking "isPopoverVisible" property, it seems can solved the problem... But am I using a correct way to solve the problem? Do you have any ideas on this?

Thanks for your reply.
cthesky is offline   Reply With Quote
Old 02-08-2012, 09:29 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Illinois
Posts: 44
GHuebner is on a distinguished road
Default

I thought you were having the issue with one popover. I don't know the proper way to have two bar button items with two popover views.

I would think to dismiss one before the other one opens. Maybe someone else encountered this issue before. I would be interested in their approach.

Quote:
Originally Posted by cthesky View Post
Hi,

Yes, at first I also display pop over by checking whether the pop over is nil. So, at that time I reset the popover controller back to nil inside popoverControllerDidDismissPopover method. But I have two bar buttons that used to pop up two different pop over controller in same interface. So, I face a problem in a case below:

- When I click both bar buttons, both pop overs will be displayed.
- Then, when I clicked outside the pop over views to dismiss the pop over, both pop over controllers set back to nil but what happens in interface is it just dismiss one of the pop overs.
- So, when I click the bar button again ( the bar button with the pop over still visible), since its pop over controller is set to nil already, it recreate and represent it and cause my app crash. But this time the crash message become "Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.".


So, when I display the pop overs by checking "isPopoverVisible" property, it seems can solved the problem... But am I using a correct way to solve the problem? Do you have any ideas on this?

Thanks for your reply.
GHuebner is offline   Reply With Quote
Old 02-08-2012, 09:40 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 38
cthesky is on a distinguished road
Default

Quote:
Originally Posted by GHuebner View Post
I thought you were having the issue with one popover. I don't know the proper way to have two bar button items with two popover views.

I would think to dismiss one before the other one opens. Maybe someone else encountered this issue before. I would be interested in their approach.
Thanks for your reply Your suggestion and opinion is quite nice. I also interested in their approach. Hope someone can share some opinions and ideas.

Any suggestions are appreciated and welcome. Thanks.
cthesky is offline   Reply With Quote
Old 02-08-2012, 10:18 PM   #8 (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

isPopoverVisible is the correct way.
__________________
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 02-08-2012, 10:41 PM   #9 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 38
cthesky is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
isPopoverVisible is the correct way.
ok. Thanks.
cthesky 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: 397
12 members and 385 guests
chiataytuday, chits12345, fiftysixty, gmarro, iOS.Lover, KennyChong, kilobytedump, Leslie80, Matrix23, ryantcb, xerohuang, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

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