[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",_phoneNumber]]];數組
調用系統的發送短信的界面,須要引入如下頭文件:atom
#import <MessageUI/MessageUI.h>spa
系統短信界面的調用很簡單,只需下面幾句代碼:.net
MFMessageComposeViewController * con = [[MFMessageComposeViewController alloc]init]; if ([MFMessageComposeViewController canSendText]) { con.recipients=@[_phoneNumber];//電話數組 con.messageComposeDelegate=self; [self presentViewController:con animated:YES completion:nil];
下面將MessageUI的一些經常使用方法總結以下:3d
+ (BOOL)canSendText代理
判斷是否支持發送文字code
+ (BOOL)canSendSubject;orm
判斷是否支持發送主題信息ip
+ (BOOL)canSendAttachments;ci
判斷是否支持發送附件
+ (BOOL)isSupportedAttachmentUTI:(NSString *)uti;
判斷是否支持統一標示附件
- (void)disableUserAttachments;
禁止發送附件
@property(nonatomic,copy) NSArray *recipients;
聯繫人數組,會顯示在發送人列表裏
@property(nonatomic,copy) NSString *body;
信息主體內容
@property(nonatomic,copy) NSString *subject;
信息標題
@property(nonatomic,copy, readonly) NSArray *attachments;
信息附件數組 只讀的 裏面是字典
- (BOOL)addAttachmentURL:(NSURL *)attachmentURL withAlternateFilename:(NSString *)alternateFilename;
根據URL路徑和添加附件,返回YES表示添加成功
- (BOOL)addAttachmentData:(NSData *)attachmentData typeIdentifier:(NSString *)uti filename:(NSString *)filename;
根據Data數據添加附件
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result;
MFMessageComposeViewControllerDelegate的代理方法,result會傳回來一個結果,枚舉以下:
enum MessageComposeResult { //取消發送 MessageComposeResultCancelled, //發送成功 MessageComposeResultSent, //發送失敗 MessageComposeResultFailed };
專一技術,熱愛生活,交流技術,也作朋友。
——琿少 QQ羣:203317592