ios判断设备能否打电话、发短信

来源:互联网 发布:c语言const的作用 编辑:程序博客网 时间:2024/05/16 11:36
//判断能否打电话NSString *deviceType = [UIDevice currentDevice].model;if([deviceType  isEqualToString:@"iPod touch"]||[deviceType  isEqualToString:@"iPad"]||[deviceType  isEqualToString:@"iPhone Simulator"]){UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"您的设备不能打电话" delegate:nil cancelButtonTitle:@"好的,知道了" otherButtonTitles:nil,nil];[alert show];}else{   //打电话的方法}


//判断能否发短信
1、引入MessageUI.framework

2、#import <MessageUI/MessageUI.h>

//发送短信方法Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));<pre><span style="color:#0000ff;">if</span><span style="color:#000000;"> ([messageClass canSendText]) {</span>

//发送短信
}else{
UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该设备没有发送短信的功能~" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];            [alterView show];
}


0 0