Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:47:05+00:00 2026-05-30T12:47:05+00:00

Im showing the AirPrint options from a UIButton using the presentFromRect method, everything is

  • 0

Im showing the AirPrint options from a UIButton using the presentFromRect method, everything is working as expected, but if i keep pressing the button fast enough my app crashes with EXC_BAD_ACCESS, probably because of the popover not being release.

Im using Xcode 4.2 with ARC enabled.

Any help would be great!

Update 2: The problem only occur on iOS 5 simulator, iPad 4.3 simulator works as expected.

Update:

Here is the real problem:

* Terminating app due to uncaught exception ‘NSGenericException’, reason: ‘-[UIPopoverController dealloc] reached while popover is still visible.’

Here is the code:

Here I’m calling my method:

PrintUtils* printUtils = [[PrintUtils alloc] init];
printUtils.delegate = self;
[printUtils setHeader:@"Header"];
[printUtils print:self.webView fromRect:self.myButton.frame inView:self.menuView];

My method:

- (void)print:(UIWebView *)webView fromRect:(CGRect)rect inView:(UIView *)view
{

    printController = [UIPrintInteractionController sharedPrintController];
    [printController setDelegate:self];


    if(!printController){

        NSError* error = [[NSError alloc] initWithDomain:@"Print unavailable!" code:0 userInfo:nil];

        [self showError:error];
        return;
    }

    UIPrintInteractionCompletionHandler completionHandler = 
    ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
        if(!completed && error){
            [self showError:error];
        }
    };

    UIPrintInfo* printInfo = [UIPrintInfo printInfo];
    [printInfo setJobName:header];
    [printInfo setDuplex:UIPrintInfoDuplexLongEdge];
    [printInfo setOutputType:UIPrintInfoOutputGeneral];

    UIPrintFormatter* viewFormatter = [webView viewPrintFormatter];

    CustomPrintPageRenderer *pageRenderer = [[CustomPrintPageRenderer alloc] init];    
    [pageRenderer setJobTitle:[printInfo jobName]];

    UIFont* font = [UIFont fontWithName:@"Helvetica" size:HEADER_FOOTER_TEXT_HEIGHT]; 
    CGSize titleSize = [pageRenderer.jobTitle sizeWithFont:font];
    pageRenderer.headerHeight = pageRenderer.footerHeight = titleSize.height + HEADER_FOOTER_MARGIN_PADDING;


    [pageRenderer addPrintFormatter:viewFormatter startingAtPageAtIndex:0];

    [printController setPrintPageRenderer:pageRenderer];
    [printController setPrintInfo:printInfo];    
    [printController setPrintFormatter:viewFormatter];
    [printController setShowsPageRange:YES];    
    [printController presentFromRect:rect inView:view animated:YES completionHandler:completionHandler];

}

My attempt to fix the problem implementing the UIPrintInteractionControllerDelegate Method:

- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
{

    if (visible) {
        [printController dismissAnimated:YES];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:47:07+00:00Added an answer on May 30, 2026 at 12:47 pm

    Did you ever figure this out? The problem is that you´re not checking if the device is an iPad or iPhone. iPhone does not support presentFromRect: but iPad does. That’s why you get the bad access when you run it on iPhone.

    Here’s what you need to do:

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    
        [printController presentFromFromBarButtonItem:sender animated:YES completionHandler:completionHandler];
    
    } else {
    
        [printController presentAnimated:YES completionHandler:completionHandler];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When showing my main window, I make a list of objects from linq-to-sql: using
When showing data from a mysql table on an php page does it have
JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user
Play Button is showing and when i hit play button it is playing audio
vwSalesByHour works as expected showing only records for hours in which there were sales.
Showing a 'share' link in a textfield within a tooltip using qTip2 . The
Im showing a video int my application, but its being chopped up, its locally
When showing a secondary form from the main form and from the second form
Showing dynamic data in table cell make problem for me. I am using [titleString
I'm showing images from other websites as thumbnails. To do this I display them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.