IPhone : App crashes while displaying print option from UIButton?

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

In my app I am displaying Print option from UIButton using following code. UIPrintInfo* printInfo = UIPrintInfo printInfo; printInfo. OutputType = UIPrintInfoOutputGeneral; printInfo.

JobName = NSLocalizedString(@"Offerings", @""); UIMarkupTextPrintFormatter *formatter = UIMarkupTextPrintFormatter alloc initWithMarkupText:@"Share"; formatter. StartPage = 0; CGFloat margin = 72.0f * 0.1f; formatter. ContentInsets = UIEdgeInsetsMake(margin, margin, margin, margin); UIPrintInteractionController* pic = UIPrintInteractionController sharedPrintController; pic.

Delegate = self; pic. ShowsPageRange = YES; pic. PrintInfo = printInfo; pic.

PrintFormatter = formatter; formatter release; void (^completionHandler)(UIPrintInteractionController*, BOOL, NSError*) = ^(UIPrintInteractionController* printController, BOOL completed, NSError* error) { if (!completed && error) { UIAlertView* alert = UIAlertView alloc initWithTitle:NSLocalizedString(@"Printing Error", @"") message:error localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil; alert show; alert release; } }; I have tried following options. Pic presentAnimated:YES completionHandler:completionHandler; OR pic presentFromRect:CGRectMake(btnPrint.frame.origin. X, btnPrint.frame.origin.

Y, btnPrint.frame.size. Width, btnPrint.frame.size. Height) inView:self.

View animated:YES completionHandler:completionHandler; But it crashes with error : EXE_BAD_ACCESS But when I tried following code for displaying print option, It works fine. Pic presentFromBarButtonItem:self.navigationItem. RightBarButtonItem animated:YES completionHandler:completionHandler; Now, I am not using navigation controller.

So I can't use this above method. What should I do? Iphone objective-c cocoa-touch iphone-sdk-4.0 link|improve this question edited Aug 17 '11 at 5:50 asked Aug 17 '11 at 5:45Devang1,929529 81% accept rate.

The whole method. – Dylan Reich Aug 17 '11 at 5:48 @Dylan : Check out my updated question. – Devang Aug 17 '11 at 5:50.

For printing we have to use object of UIPrintInteractionController which is pic. And it contains only above three methods. Which will handle other things like Printer selection , Number of pages and etc. – Devang Aug 17 '11 at 6:17 Ok, so I'll assume that you have UIPrintInteractionController *pic; somewhere in your .

H file. But before you try any of these methods, do you have pic = UIPrintInteractionController alloc init;? – Dylan Reich Aug 17 '11 at 6:20 No it just required sharedPrintController which I have done in this same coding.

See its available in question – Devang Aug 17 '11 at 6:25 Try changing that line to: UIPrintInteractionController* pic = UIPrintInteractionController sharedPrintController alloc init; – Dylan Reich Aug 17 '11 at 6:28 Crash Invalid argument type! – Devang Aug 17 '11 at 6:31.

Ok. I have solved my problem. The view where you are going to give print option.

It should be contain navigation controller. So, My solution First *first = First alloc initWithNibName:@"First"; UINavigationController *nav = UINavigationController alloc initWithRootView:@"first"; self presentViewController:nav animated:YES; Its strange solution. But worked for me.

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