1. 程式人生 > >IOS網路、多執行緒、shareSDK-使用UIApplaction進行簡單操作

IOS網路、多執行緒、shareSDK-使用UIApplaction進行簡單操作

//
//  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()     } }