xcode 第二个视图控制器中的“下一步”按钮出错

monwx1rj  于 2022-12-05  发布在  其他
关注(0)|答案(1)|浏览(98)

由于某种原因,第二个视图控制器上的按钮不起作用。当我在我的设备上测试代码时,它给我这个错误:线程1:“-[抑郁症应用程序1.第二视图控制器下一个按钮]:发送到示例0x 103605560的选择器无法识别”
有人能找到错误吗?
下面是第二个视图控制器的代码

import UIKit

class SecondViewController: UIViewController, UINavigationControllerDelegate{
    override func viewDidLoad(){
        
        super.viewDidLoad()
        
    }
    
    @IBAction func nextButton(){
       let vc = storyboard?.instantiateViewController(withIdentifier: "third") as! ThirdViewController
          vc.modalPresentationStyle = .overFullScreen
          present(vc,animated: true)
      }
    
    @IBAction func prevbutton(){
    
        let vc = storyboard?.instantiateViewController(withIdentifier: "") as! ViewController
        vc.modalPresentationStyle = .overFullScreen
        present(vc,animated: true)
    }
    
    
}

下面是我的第一个视图控制器的代码

import UIKit
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet weak var imageview: UIImageView!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    @IBAction func Btnimagepicker(_ sender: Any) {
        let picker = UIImagePickerController()
        picker.allowsEditing=true
        picker.delegate=self
        present(picker, animated:true)
    }
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        guard let image=info[.editedImage] as? UIImage else {return}
        imageview.image=image
        dismiss(animated:true)
    
    }
    @IBAction func didTapButton(){
        let vc = storyboard?.instantiateViewController(withIdentifier: "second") as! SecondViewController
        vc.modalPresentationStyle = .fullScreen
        present(vc,animated: true)
    }
}

下面是我的第三个视图控制器的代码

import UIKit

class ThirdViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    

    @IBOutlet weak var Text: UITextView!
    /*
    // MARK: - Navigation

     @IBOutlet weak var Text: UITextView!
     // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

基本上,第一个视图控制器应该让用户选择一个图像并转到下一个视图控制器。而在第二个视图控制器中,用户应该能够回到第一个视图控制器,或者转到第三个视图控制器。

oogrdqng

oogrdqng1#

确保您的@IBOutlet正确连接到笔尖。大多数时候我遇到这样的错误是由于错过连接或一个ILD连接没有删除。如果您将上传一个链接到一个有这个问题的项目,它将很容易找到和修复

相关问题