版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21153627/article/details/84326474
//
// ViewController.swift
// Dome2test
//
// Created by 郭文亮 on 2018/11/21.
// Copyright © 2018年 finalliang. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
test5()
}
//使用UIApplaction对象打开地图
func test5() {
var address = "Beijing"
address = address.addingPercentEncoding(withAllowedCharacters: CharacterSet())!
let urlText = "https://maps.google.cn/maps?q=\(address)"
let url = URL(string: urlText)
UIApplication.shared.openURL(url!)
}
//使用UIApplaction对象发送邮件
func test4() {
let tel = "mailto:[email protected]"
let url = URL(string: tel)
UIApplication.shared.openURL(url!)
print("1")
}
//使用UIApplaction对象发送短信
func test3() {
let tel = "sms:15234156325"
let url = URL(string: tel)
UIApplication.shared.openURL(url!)
}
//使用UIApplaction对象拨打电话 需真机测试
func test2() {
let tel = "tel:15234156325"
let url = URL(string: tel)
print("1")
UIApplication.shared.openURL(url!)
print("2")
}
//使用UIApplaction对象打开网页
func test1() {
let website = "http://www.baidu.com"
let url = URL(string: website)
UIApplication.shared.openURL(url!)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}