how to attach files for mailing in xcode - iphone

I have a mailcomposer in which i have attached a file through coding(hard-coded)..
I need to have a button so that When i press the button.It should ask which file to attach...
My code is shown below in which i am attaching the file hordcoded...
UIImage *img=[UIImage imageNamed:#"Mehmood.jpg"];
NSData *imgData=UIImageJPEGRepresentation(img, 1);
[composer addAttachmentData:imgData mimeType:#"image/jpeg" fileName:#"Mehmood.jpg"];
Even I need to attach any file which i am selecting after button click(not the specific one like png/jpeg)...
Please help...
Thanks in advance

maybe this will help you.
Where's the iPhone MIME type database?

You cannot really modify the standard mail composer window to add your own buttons. You should ask the user what they want to attach before presenting the mail composer.

Related

PDF Attachments sent from iOS Not Displayed Properly in Outlook Mail Client

When I send an e-mail with a PDF attachment from an iOS device, the PDF attachment doesn't get displayed properly in the Outlook mail client. Here is how it looks like:
(The attachment PDF is actually sent, if you right click the e-mail and select 'View Attachments', then you will be able to view the PDF. However, with the red cross the customers think that the attachment wasn't properly attached.)
Here is the code that sends the e-mail:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setToRecipients:#[#"test#test.com"]];
[controller setSubject:#"Subject"];
[controller setMessageBody:emailData.emailBody isHTML:YES];
[controller addAttachmentData:emailData.reportData mimeType:#"application/pdf" fileName:emailData.reportName];
[self presentViewController:controller animated:YES completion:nil];
There is a workaround: If you set the message body as not HTML ([setMessageBody:isHTML:]), then the attachment is correctly displayed in Outlook. However, this means that you can't properly format the e-mail text and also can't add any kind of HTML signature to the e-mail.
This problem occurs with iOS7; I can't remember too well but I think the attachments were fine in iOS6.
Is it possible to have the e-mail HTML formatted and have the PDF attachment looking good in Outlook? Is the problem at the e-mail creation part or more at the Outlook side? The other e-mail clients (Gmail or Yahoo) seem to be handling this well.
We were working on the same issue and our team spent all day on this one today. One thing that we discovered today is that if the PDF only has one page, it will cause the the error. However, when we added a second blank page to the PDF, then the PDF came through properly as an attachment.
It looks like Outlook is trying to display a single page PDF inline rather than as an attachment. If you add the second page, it worked fine.
Hope that helps.
Did you got reason why PDF attach as in-line instead normal attachment in email?
Know When Mac OS X Mail Will Show a PDF Inline, When as an Icon
To know whether Mac OS X Mail will display a PDF file attachment as an icon or inline, look at the file's length:
PDF files of only one page are displayed inline in the message text.
PDF files with two or more pages are shown as icons.
For the single-page PDF files, you can switch between inline and icon display by selecting View as Icon or View in Place from the context menu respectively. To open the context menu, click on the PDF (shown inline or as an icon) with the right mouse button, click with the left mouse button while holding down Ctrl or tap with two fingers on the trackpad while the mouse cursor is over the PDF.
The following works for me:
// Should octet-stream be more specific for a PDF file?
// YES: It seems that earlier (was this iOS6 or iOS7, before iOS7.1?) that the PDF icon showed up properly with just the #"application/octet-stream" and the fileName having .pdf. However, just now (3/30/14), with iOS7, the PDF icon only showed up when I changed the MIME type to #"application/pdf"
[email addAttachmentData:data
mimeType:#"application/pdf" // #"application/octet-stream"
fileName:justFileName];
Check this http://email.about.com/od/macosxmailtips/qt/et080506.htm
PDF files of only one page are displayed inline in the message text.
PDF files with two or more pages are shown as icons.
I've been working the same problem myself and I've been having all sorts of problems (blog post to my users at https://easybooksapp.com/blog/media-types-for-pdf-attachments).
For most people it's fine, the PDF appears in their mail client fine. But for some mail clients such as Outlook and when viewing Gmail in Chrome I see the same error you're seeing. The attached PDF appears as a broken image, despite the attached file being sent as the correct MIME type (application/pdf). I narrowed this down to a problem in how the Mail app on iOS encodes the attachment when the user has an HTML signature set in their iOS Mail settings. If their signature includes an embedded image (the image data is included in the message) this causes the problem. When users delete their signature and replace it with a plain text or simple html signature it's all fine!
Today I was about to start working on finding out the differences between how OS X and iOS send the mail, as under OS X the mail is received okay. I just repeated the same tests today to discover the problem seems to have gone away in iOS 7.1. To confirm it I've repeated the exact same steps on an older iPad that still has iOS 7.0 and the problem exists as before.
So it looks like it was in fact an iOS problem in the end.
CORRECTION:
I've updated the iPad from iOS 7.0 to 7.1 and the problem still exists. I will have to do some more work to find out what the difference in encoding is between OS X and iOS 7.
Use text/pdf instead of application/pdf.

copy paste text and image both to clipboard in iphone app

I am working on an app where I want to copy some text and image and allow user to paste it anywhere. I know it is done using UIPasteboard and I have implemented copying of image but now I want to copy image and text both and then let user paste it. There can be several images and text messages which can come in any order. It is like a paragraph being written with text and images. Is this possible? Can someone suggest me how can I achieve it?
Regards
Pankaj
You can put anything you wish in the pasteboard, including multiple entries like of type UIPasteboardTypeListString and another of type UIPasteboardTypeListImage, and even another of type #"My Made-Up Type". Think of it as a shared mutable dictionary.
It's up to the receiving application to understand what to do with them.

Add an icon to a Perl/GTK application

I've written a little app in perl/Gtk, now I want to add an icon to it. I"ve got a jpg file.
The app is very basic, and of course use a Gtk2::Window object.
I was thought to use Image::Base::Gtk2::Gdk::Pixbuf but Gtk2::Window->set_default_icon only want a Gtk2::Gdk::Pixbuf object, and I have not managed to create one (if someone can show me). I'm on a debian with perl-5.14.2.
Thanks guys!
Oh, got it!
use Image::Base::Gtk2::Gdk::Pixbuf;
my $navIco = Gtk2::Gdk::Pixbuf->new_from_file("./mltwb.png"); `
$window->set_default_icon($navIco);`
Just had to read doc. Thanks folks!

iPhone action button image file available anywhere?

I'm working on an app and want to use the image from the action type toolbar button (the one with the arrow coming from the box that we often use for share etc) in a custom button. Is there some way I can get hold of the .png for it?
Thanks
There is the open source UIKit artwork extractor project available at Github: https://github.com/0xced/UIKit-Artwork-Extractor
There's a mockup toolkit available for iOS SDK at http://blog.metaspark.com/2009/02/fireworks-toolkit-for-creating-iphone-ui-mockups/
Check the fourth image on right most column. I hope it contains the image you want.
You can download the mockup toolkit and open up with fireworks or photoshop to extract images from there. If you don't have these adobe softwares then the open source software GIMP is your good friend to extract the image.
There really is no need to duplicate the image content since its already in the framework.
Have a look at this code:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:#selector(onActionButtonClicked:)];
The relevant portion being the initWithBarButtonSystemItem initialization method.
This question may also be more useful in answering this question than the selected answer.

how to do localization for iphone

i got button....
displays on button
Search...
when i selected localization.....
i need to display
Zoeken
for search button its displays Zoeken...
#All thanks in advance.
You should look at NSLocalizedStringWithDefaultValue:
NSString *buttonTitle = NSLocalizedStringWithDefaultValue(#"KEY", nil, [NSBundle mainBundle], #"VISIBLE_DESCRIPTION", #"DEVELOPER_DESCRIPTION");
[aButton setTitle:buttonTitle forState:UIControlState...];
You'll then need to provide the relevant localization files in your project for the languages you intended on targeting.
As a top level skim, you can create per-locale NIB and string resource files using the built-in internationalisation capabilites.
However, this is quite a broad topic (there's an entire section of the Apple developer site dedicated entirely to internationalisation, complete with sample code, etc.), so what you need to do it read the documents there, look at the sample code and then ask a more targeted question if you get stuck/have a specific issue.