<span style="background-color: rgb(102, 102, 204);">//
// TelePhoneHelper.m
// TelePhoneHelper
//
// Created by xiaoyao on 14/12/1.
// Copyright (c) 2014年 lijien. All rights reserved.
//
#import "TelePhoneHelper.h"
@implementation TelePhoneHelper
// 调起系统电话
+ (void)systemTelePhoneNumber:(NSString *)telePhone {
NSString *teleString = [NSString stringWithFormat:@"tel://%@", telePhone];
NSURL *teleUrl = [NSURL URLWithString:teleString];
[[UIApplication sharedApplication] openURL:teleUrl];
return;
}
@end
//
// TelePhoneHelpViewController.m
// TelePhoneHelper
//
// Created by xiaoyao on 14/12/1.
// Copyright (c) 2014年 lijien. All rights reserved.
//
#import "TelePhoneHelpViewController.h"
#import "TelePhoneHelper.h"
@interface TelePhoneHelpViewController ()
@end
@implementation TelePhoneHelpViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *tpButton = [UIButton buttonWithType:UIButtonTypeCustom];
tpButton.frame = CGRectMake(100, 180, 100, 50);
tpButton.backgroundColor = [UIColor blueColor];
[tpButton setTitle:@"拨打电话" forState:UIControlStateNormal];
[tpButton addTarget:self action:@selector(teleCicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tpButton];
return;
}
- (void)teleCicked:(UIButton *)btn {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"美容客服热线"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:@"呼叫"
otherButtonTitles:nil, nil];
[sheet showInView:self.view];
return;
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[TelePhoneHelper systemTelePhoneNumber:@"1001011"];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
</span>
调起系统拨打电话
最新推荐文章于 2023-10-28 09:09:14 发布