ios学习笔记之-点击一个按钮弹出拨打电话提示框
来源:互联网 发布:抠图算法 编辑:程序博客网 时间:2024/06/10 19:55
按钮的代码就不写了。直接写主要代码。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
<string>telprompt</string>
</array>
plist里加上述代码就是意思申请打电话权限
-(void)callPhoneStr:(NSString*)phoneStr {
NSString *str2 = [[UIDevicecurrentDevice] systemVersion];
if ([str2compare:@"10.2"options:NSNumericSearch] ==NSOrderedDescending || [str2compare:@"10.2"options:NSNumericSearch] ==NSOrderedSame)
{
NSLog(@">=10.2");
NSString* PhoneStr = [NSStringstringWithFormat:@"tel://%@",phoneStr];
if ([PhoneStrhasPrefix:@"sms:"] || [PhoneStrhasPrefix:@"tel:"]) {
UIApplication * app = [UIApplicationsharedApplication];
if ([appcanOpenURL:[NSURLURLWithString:PhoneStr]]) {
[app openURL:[NSURLURLWithString:PhoneStr ]options:@{}completionHandler:nil ];
}
}
}else {
NSMutableString* str1 = [[NSMutableStringalloc]initWithString:phoneStr];//存在堆区,可变字符串
NSString * str = [NSStringstringWithFormat:@"是否拨打电话\n%@",str1];
UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:strmessage: nilpreferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertActionactionWithTitle:@"呼叫"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction *action) {
NSLog(@"点击了呼叫按钮10.2下");
NSString* PhoneStr = [NSStringstringWithFormat:@"tel://%@",phoneStr];
if ([PhoneStrhasPrefix:@"sms:"] || [PhoneStrhasPrefix:@"tel:"]) {
UIApplication * app = [UIApplicationsharedApplication];
if ([appcanOpenURL:[NSURLURLWithString:PhoneStr]]) {
[app UIApplication:[NSURLURLWithString:PhoneStr]];
}
}
}]];
[alert addAction:[UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *action) {
NSLog(@"点击了取消按钮");
}]];
[selfpresentViewController:alertanimated:YEScompletion:nil];
}
}
一定要区分一下ios系统版本,因为api是不一样的,因为版本不一样,方法是不一样的。10.2那个里面的方法自己可以弹出一个弹出框,另外一个需要用UIAlertController来制作弹出框。
这里推荐一个
http://www.cocoachina.com/ios/20161021/17824.html
- ios学习笔记之-点击一个按钮弹出拨打电话提示框
- iOS 点击按钮实现拨打电话,发送短信功能
- ios开发之拨打电话
- 五 :ios学习笔记 拨打电话 发短信 发邮件
- iOS开发点击数字拨打电话
- ios lable中电话号码点击拨打电话
- Android 点击按钮弹出提示框实例
- android学习笔记之调用拨号界面拨打电话
- 关于iOS 10以上调用系统拨打电话方法,弹出框弹出变慢的问题
- 安卓自定义弹出对话框点击直接拨打电话
- 手机访问页面电话号码,点击弹出拨打电话
- 点击按钮弹出对话框提示
- iOS开发 iOS 10拨打系统电话,弹出框延迟出现问题
- Android学习笔记_1_拨打电话
- IOS加载网页后点击页面号码拨打电话实例
- iOS 点击号码拨打电话三种方式
- 点击按钮显示一个弹出框,点击一个弹出框以外的区域,隐藏弹出框
- C#之WinForm基础 点击按钮出现一个只有确定按钮和文字的提示框
- 续:在RAD中配置JPA(EclipseLink): Java EE环境
- spring mvc各种注解
- wordpress本地局域网访问问题
- curl、fopen和file_get_contents区别
- mysql 1115-unknown character set XXXX
- ios学习笔记之-点击一个按钮弹出拨打电话提示框
- webrtcglossary.com
- properties文件、getResouce()方法、getResourceAsStream()方法
- 20170227. EXIF信息的说明(opencv320 ApplyExifOrientation)
- android禁止EditText输入emoji表情图片
- ViewPager+FragmentPagerAdapter刷新
- 原码,反码和补码
- android blogs
- RN源码分析