打开网页的操作 发短信等

打开网页 现在main.storyboard中添加一个按钮 随后为其关连事件,当按下这个按钮时,跳转界面到网页

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func tiaozhuan(sender: UIButton) {
        //打开网页的代码
    UIApplication.sharedApplication().openURL(NSURL(string: "http://www.baidu.com")!)
    }

}

实质上都是遵守协议 一个是http的协议 发短信是sms的协议 电话是tel的协议 发邮件是mailto 的协议

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func tiaozhuan(sender: UIButton) {
        //打开网页的代码
    UIApplication.sharedApplication().openURL(NSURL(string: "tel:\\10086")!)
    }

}
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func tiaozhuan(sender: UIButton) {
        //打开网页的代码
    UIApplication.sharedApplication().openURL(NSURL(string: "sms:\\10086")!)
    }

}
发邮件

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func tiaozhuan(sender: UIButton) {
        //打开网页的代码
    UIApplication.sharedApplication().openURL(NSURL(string: "mailto:\\10086")!)
    }

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值