- 浏览: 161490 次
- 性别:
- 来自: 大连
最新评论
-
xueyw:
http://www.devdiv.com/forum-iph ...
iPhone开发网站、论坛、博客 -
Meggie_love:
受教了
游戏算法整理 算法七 无限大地图的实现 -
xueyw:
http://www.devdiv.net/bbs/forum ...
iPhone开发网站、论坛、博客 -
junlas:
APE 物理引擎与 Box2D 物理引擎对比 -
ha397666:
5、扩展的点已经被扩展过了。当扩展节点的时候,每个节点都是向四 ...
游戏算法整理 算法六:关于SLG中人物可到达范围计算的想法
A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off your app and make your app look more professional and make it easier on the user by filling in the To and Subject for them. They are also able to change the From to whatever email then want you to receive an email from just like you can do in the Mail app. So todays tutorial is gonna show you how to email within your application. We will be using the MessageUI framework and we will also include an attachment in the email. Theres a screenshot to the left of how it will look. So lets get started… You can name yours whatever you want, in the tutorial I will be referring it as the NameViewControllers. 2. Import The Frameworks The first thing we need to do is import the framework. So go to your Frameworks folder in the Files In Pain section on the left. Open the folder and right click one of the frameworks and click “Reveal In Finder.” Heres a screenshot on what you should do. 3. Implementing The Code Now that we have imported the framework lets get into some coding. So go ahead and jump in the NameViewController.H and make an IBAction for a button. Then copy that code and paste it in the NameViewController.M with curly brackets. Also make sure to add the button in Interface Builder and link it up with a Touch Up Inside method. You guys are at the point to knowing how to hook up actions and dragging stuff into Interface Builder. After that we want to on the top of the NameViewController.h import the framework. So on the top do #import “MessageUI/MessageUI.h” and the reason why we do this is because we must import out MessageUI framework to make calls to the associated header files. Now we need to also put in the delegate protocols for this framework. @interface NameViewController: UIViewController do this code <MFMailComposeViewControllerDelegate, UINavigationControllerDelegate>. Heres the code here for the NameViewController.H #import <MessageUI/MessageUI.h> @interface MailComposerViewController : UIViewController <MFMailComposeViewControllerDelegate,UINavigationControllerDelegate> { } -(IBAction)pushEmail; @end
Now after your done with the .H jump into the .M viewcontroller. Now in your button action code do this: -(IBAction)pushEmail { MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; mail.mailComposeDelegate = self; if ([MFMailComposeViewController canSendMail]) { //Setting up the Subject, recipients, and message body. [mail setToRecipients:[NSArray arrayWithObjects:@"email@email.com",nil]]; [mail setSubject:@"Subject of Email"]; [mail setMessageBody:@"Message of email" isHTML:NO]; //Present the mail view controller [self presentModalViewController:mail animated:YES]; } //release the mail [mail release]; } //This is one of the delegate methods that handles success or failure //and dismisses the mail - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissModalViewControllerAnimated:YES]; if (result == MFMailComposeResultFailed) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Message Failed!” message:@”Your email has failed to send” delegate:self cancelButtonTitle:@”Dismiss” otherButtonTitles:nil]; [alert show]; [alert release]; } }
What if we wanted to include an image attachment to the email? Well its quite simple. Just add this to the code right under the part where you set up the Recipient, Subject, and the Message. UIImage *pic = [UIImage imageNamed:@"Funny.png"]; NSData *exportData = UIImageJPEGRepresentation(pic ,1.0); [mail addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Picture.jpeg"];
Now we are setting up the MailComposer in the first part of the code in the action. Then we call a didFinishWithResult method where we are setting up if the email fails or sends. Also it sets up a Cancel button for you so we have to call the dismiss method so that it works. In the attachment code just edit the imageNamed:@”" with your images name.That is basically it! The source code is below for the people that just doesn’t wanna copy and paste or type… I am just jking with you guys. Happy iCoding! from:http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/
1. Create A New View Based Application
Go ahead and look for the “MessageUI.framework” and highlight it then drag it into your frameworks folder. Make sure that when you click Add on the thing that makes sure you want to import it that “Copy items into destination group’s folder (if needed)” is not check. Thats a very important step or you will have big time problems and you do this with any frameworks you would ever use in the future.
发表评论
-
UIPickerView – spinning multiple components
2010-08-24 16:24 1614I found an interesting issues w ... -
UITableView效果收集
2010-07-10 12:28 2904某些打不开需翻()墙 Customizing the bac ... -
日期处理
2010-03-17 22:58 1176NSDateFormatter *dateFor ... -
uninstall xcode
2010-02-08 02:35 1730How to uninstall Xcode and ... -
从一个url中获得文本信息(转)
2010-01-21 11:37 1384有时候你可能需要从一个url中获取一个文本文件中的信息。 下面 ... -
将图片保存在iPhone的相册中(转)
2010-01-21 11:28 2923有时候你的应用需要将应用中的图片保存到用户iPhone或者iT ... -
一些遊戲製作有關的博客(转)
2010-01-20 14:57 1168站長在收集站內朋友的博客,然後把它們列出來方便大家看,這的確是 ... -
Beautiful Snowflakes
2010-01-14 18:51 1460It is a application that displa ... -
Layer Programming with Quartz Core
2010-01-08 14:11 3519《转载》 2009/6/25 ... -
如何移除Three20中private API
2010-01-07 22:04 1831Three20 是一个非常有 ... -
iphone下Three20库(From Facebook)的设置使用方法
2010-01-07 22:03 4025Three20是一个编译的静态类库 ,在Xcode中的项目实 ... -
Opera Masks
2010-01-07 01:13 1682It is a application that introd ... -
Java读取星际译王(StarDict)词库
2010-01-06 18:08 2620下面的文件是StarDict的词库格式说明文件: Form ... -
iPhone Coding Tutorial – Creating an Online Leaderboard For Your Games4
2010-01-06 11:06 1520Submitting High Scores To The ... -
iPhone Coding Tutorial – Creating an Online Leaderboard For Your Games3
2010-01-06 11:02 1065Displaying The Scores Table ... -
iPhone Coding Tutorial – Creating an Online Leaderboard For Your Games2
2010-01-06 11:01 730Inserting Scores Into The Dat ... -
iPhone Coding Tutorial – Creating an Online Leaderboard For Your Games1
2010-01-06 10:59 1087As you may have seen, there a ... -
iPhone Coding Tutorial – Inserting A UITextField In A UIAlertView
2010-01-06 10:44 1607This will be a simple tutorial ... -
Objective-C内存管理总结〜CC专版
2009-12-28 11:09 3010之前写过类似的文章,这篇以做总结,希望能帮助刚上船的兄弟。^_ ... -
tell user the status
2009-12-17 17:42 1210+(UIView *)waitingView { ...
相关推荐
这篇教程“iPhone Coding Tutorial – Inserting A UITextField In A UIAlertViewController”将会教你如何在现代iOS环境中,在警告视图控制器中添加一个文本字段。 首先,我们需要了解`UIAlertController`的基本...
本文《Multicast with Network Coding in Application-Layer Overlay Networks》深入探讨了如何利用应用层覆盖网络的独特属性,通过引入网络编码技术,显著提升端到端的组播吞吐量。 #### 应用层覆盖网络特性 应用...
Each chapter in Coding Games in Python shows how to construct a complete working game in simple numbered steps. The book teaches how to use freely available resources, such as PyGame Zero and Blender,...
Using fun graphics and easy-to-follow instructions, Coding Projects in Python is a straightforward, visual guide that shows young learners how to build their own computer projects using Python, an ...
《Coding Games in Scratch》是一本面向初学者的编程教材,主要使用Scratch编程语言来教授游戏开发的基础知识。Scratch是由麻省理工学院(MIT)的“终身幼儿园团队”开发的一款图形化编程工具,旨在帮助孩子们学习编程...
cvpr12_tutorial_sparse_coding.ppt
The simple, logical steps in Coding Projects in Python are fully illustrated with fun pixel art and build on the basics of coding, so kids can have the skills to build whatever kind of project they ...
Coverage of the fundamentals of coding and the applications of codes to the design of real error control systems. Contains the most recent developments of coded modulation, trellises for codes, soft-...
### 一、里德-所罗门编码(Reed-Solomon Coding)基础 里德-所罗门编码是一种非二进制线性错误校正码,广泛应用于数据存储和通信系统中,以提供强大的错误检测和纠正能力。它由Irving S. Reed和Gustave Solomon于...
1 Rotate Array in Java 15 2 Reverse Words in a String II 19 3 Evaluate Reverse Polish Notation 21 4 Isomorphic Strings 25 5 Word Ladder 27 6 Word Ladder II 29 7 Median of Two Sorted Arrays 33 8 Kth ...
百度的余凯老师在CVPR2012上的Tutorial
《Coding Projects in Scratch》这本书是DK Children在2016年7月5日出版的一本面向9至12岁青少年的编程入门指南。Scratch是由麻省理工学院(MIT)的终身幼儿园团队开发的一种图形化编程语言,它通过拖拽积木式的编程块...
"Coding Projects in Python" 和 "Coding Games in Python" 这两本书籍是DK出版的专为儿童设计的编程教育资源,旨在帮助孩子们轻松入门编程,培养他们的逻辑思维能力和问题解决技巧。 "Coding Projects in Python" ...
Coding Projects in Python 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或...
《Grokking the Coding Interview - Patterns for Coding Questions》是一份专为北美算法面试准备的压缩包资源,其中包含了多种常见的编程题目模式。这份资源旨在帮助面试者熟练掌握各种算法和数据结构,以便在面试...
Coding-Projects-in-Python.pdf