邮件、短信、相机、图库的使用
来源:互联网 发布:淘宝网服装中老年女装 编辑:程序博客网 时间:2024/05/16 01:01
转载请保留cml_cml~~~~~~
---------------------------------------------------------------------------------------------------------------1------------------------------------------------------------------------------------------------------------------
先用Storyboard拖四个按钮,与对应的controller类关联属性和方法
---------------------------------------------------------------------------------------------------------------发送邮件:--------------------------------------------------------------------------------------------------
导入MessageUI.framework
遵循MFMailComposeViewControllerDelegate协议
//发送邮件- (IBAction)mailDelivery:(id)sender { // 判断设备是否是否可以发送邮件 // NSClassFromString简单介绍http://blog.csdn.net/cml_cml/article/details/37659421 Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); NSString * feedbackMsg; //判断当前版本是否支持邮件发送 if (!mailClass) { feedbackMsg = @"当前系统版本不支持应用内发送邮件功能"; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:feedbackMsg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alertView show]; }else if(![mailClass canSendMail]) { // 判断是否设置邮件账户 feedbackMsg = @"您没有设置邮件账户"; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:feedbackMsg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alertView show]; }else{// 发送邮件 [self sendFeedBackMail]; }}-(void)sendFeedBackMail{ //是否创建邮件 BOOL judge = [MFMailComposeViewController canSendMail]; if (judge) { //创建邮件 MFMailComposeViewController *pick = [[MFMailComposeViewController alloc]init]; //标题 [pick setSubject:@"意见反馈"]; //邮件地址 NSArray *address = [NSArray arrayWithObject:@"请填上自己的邮箱"]; [pick setToRecipients:address]; //内容 NSString *message = @"你好!";// 设置代理 pick.mailComposeDelegate = self; [pick setMessageBody:message isHTML:NO]; //返回 [self presentViewController:pick animated:YES completion:NULL]; }}//代理方法-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{ NSString *title = @"邮件发送提醒"; NSString *msg; switch (result) { case MFMailComposeResultCancelled: msg = @"邮件取消!"; [self alertWithTitle:title msg:msg]; break; case MFMailComposeResultSaved: msg = @"邮件保存成功!"; [self alertWithTitle:title msg:msg]; break; case MFMailComposeResultSent: msg = @"邮件发送成功!"; [self alertWithTitle:title msg:msg]; break; case MFMailComposeResultFailed: msg =@"邮件发送失败!"; [self alertWithTitle:title msg:msg]; break; } [self dismissViewControllerAnimated:YES completion:NULL];}- (void)alertWithTitle:(NSString *)_title_ msg:(NSString *)msg{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title_ message:msg delegate:nil cancelButtonTitle:@"好" otherButtonTitles:nil]; [alert show];}
---------------------------------------------------------------------------------------------------------------发送短信------------------------------------------------------------------------------------------------------
导入MessageUI.framework
遵循MFMessageComposeViewControllerDelegate协议
//发送短信- (IBAction)noteDelivery:(id)sender { BOOL judge = [MFMessageComposeViewController canSendText]; if (judge) { MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc]init]; picker.messageComposeDelegate = self; //收件人 picker.recipients = @[@"186*******"]; //内容 picker.body = @"很高兴见到你!"; [self presentViewController:picker animated:YES completion:nil]; }else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"系统不具备此项功能!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alertView show]; }}#pragma mark--------------发送短信代理方法-----------------(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ NSString *title = @"邮件发送提醒"; NSString *msg; switch (result) { case MessageComposeResultCancelled: msg = @"短信取消!"; [self alertWithTitle:title msg:msg]; break; case MessageComposeResultSent: msg = @"短信成功发送!"; [self alertWithTitle:title msg:msg]; break; case MessageComposeResultFailed: msg = @"短信发送失败!"; [self alertWithTitle:title msg:msg]; break; } [self dismissViewControllerAnimated:YES completion:nil];}
// alertWithTitle:msg:方法与邮箱的一样
---------------------------------------------------------------------------------------------------------------相机使用------------------------------------------------------------------------------------------------------
导入UIImagePickerControllerDelegate
//使用相机功能- (IBAction)useTheCamera:(id)sender { // UIImagePickerControllerCameraDeviceRear 后置摄像头 // UIImagePickerControllerCameraDeviceFront 前置摄像头 BOOL isCamera = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]; if (!isCamera) { NSLog(@"没有摄像头"); return ; } UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.delegate = self; // 编辑模式 imagePicker.allowsEditing = YES; [self presentViewController:imagePicker animated:YES completion:nil];}//使用图库- (IBAction)galleryUse:(id)sender { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; imagePicker.delegate = self; [self presentViewController:imagePicker animated:YES completion:^{ }];}使用UIImagePickerControllerDelegateUINavigationControllerDelegate代理方法#pragma mark--------------使用相机----------------// 选中照片- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSLog(@"%@", info); UIImageView *imageView = (UIImageView *)[self.view viewWithTag:101]; // UIImagePickerControllerOriginalImage 原始图片 // UIImagePickerControllerEditedImage 编辑后图片 UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; [picker dismissViewControllerAnimated:YES completion:NULL]; }// 取消相册- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker dismissViewControllerAnimated:YES completion:NULL]; }
---------------------------------------------------------------------------------------------------------------5------------------------------------------------------------------------------------------------------------------
- 邮件、短信、相机、图库的使用
- 邮件、短信、相机、图库的使用
- android 相机与图库的简单应用
- 调用系统的图库和系统相机完成获取头像功能 包括popupWindow的使用
- Android调用相机及使用图库截取图片
- 相机拍照与图库
- 相机,图库 新
- iOS之打电话、发短信、发邮件、相机
- 关于使用安卓系统自带的相机进行拍照,把照片存到系统图库gallery中
- Android调用系统的相机,图库,以及裁剪图片功能。
- 基于opencv的相机之增加图库功能(五)
- 调用系统相机和图库册得到图片的例子
- Android 调用相机与图库的简单封装
- 调用Android的相机与图库并进行剪切
- 弹出对话框选择相机或者图库内的图片
- 使用邮件到达短信通知
- 阿里图库的简单使用
- 调用系统相机与图库
- WPF元素生命周期
- Android Touch事件传递机制
- 使用多线程异步创建一组文件
- 黑马程序员-单例模式
- cocos2d-x-2.2.4 (一) 创建工程MyGame
- 邮件、短信、相机、图库的使用
- dede前台页面实现会员的登录状态
- 关于VS调试的时候出错直接退出而不报错
- tld自定义标签系列--使用body-content的作用--比较有用
- Android模拟器无法启动
- Intel硬件加速 VS CUDA完胜 视频转码感受
- 如何生成邮件使用的状况报告
- An intro to modern OpenGL. Chapter 3: 3D transformation and projection
- Android 中自定义控件和属性(attr.xml,declare-styleable,TypedArray)的方法和使用