小编Mzo*_*och的帖子

如何在Swift3中覆盖viewWillDisappear

我试图隐藏第一个导航栏并显示所有其他导航栏,所以我使用了:

override func viewWillAppear(_ animated: Bool) {
    // Hide the navigation bar on the this view controller
    self.navigationController?.setNavigationBarHidden(true, animated: true)
}

override func viewWillDisappear(_ animated: Bool) {
    // Show the navigation bar on other view controllers
    self.navigationController?.setNavigationBarHidden(false, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

我现在需要的是调用父类的方法:super.viewWillAppear(animated)super.viewWillDisappear(animated),但我不知道在哪里或者怎么样,有什么建议?

swift swift3

5
推荐指数
1
解决办法
9364
查看次数

使用MFMessageComposeViewController发送SMS

我希望我的应用程序发送短信,我当前的代码不起作用,这是以下步骤:

import MessageUI
Run Code Online (Sandbox Code Playgroud)

添加课程:

MFMessageComposeViewControllerDelegate

然后我用了一个按钮:

 @IBAction func Messages(_ sender: UIButton) {


    if MFMessageComposeViewController.canSendText() == true{
        let recipients:[String] = ["1500"]
        let messageController = MFMessageComposeViewController()
        messageController.messageComposeDelegate  = self // implement delegate if you want
        messageController.recipients = recipients
        messageController.body = "Your_text"
        self.present(messageController, animated: true, completion: nil)

        func messageComposeViewController(controller: MFMessageComposeViewController,
                                          didFinishWithResult result: MessageComposeResult) {

            // Dismiss the message compose view controller.
            controller.dismiss(animated: true, completion: nil)}

    }}
Run Code Online (Sandbox Code Playgroud)

并使用该功能:

 func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {}
Run Code Online (Sandbox Code Playgroud)

那我错过了什么?谢谢.

swift3

1
推荐指数
1
解决办法
4378
查看次数

标签 统计

swift3 ×2

swift ×1