SecondViewControllerクラスを作りViewControllerクラスからUITextFieldを使って値を渡したいのですがエラーが出てしまいます。色々調べてみましたが他の方は問題なく出来ているようなのでどのようにすれば良いのか分かりません。よろしくお願いします。
以下、ViewControllerクラス
import UIKit class ViewController: UIViewController { @IBOutlet weak var myText:UITextField! override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } override func prepareForSegue(segue:UIStoryboardSegue,sender:AnyObject!){ var newVC:SecondViewController = segue.destinationViewController as! SecondViewController // ↑このSecondViewControllerに対して Use of undeclared type "SecondViewController"といったエラーが出てしまいます。 newVC.label = self.myText.text } }
以下、SecondViewControllerクラス
import UIKit class SecondViewController: UIViewController { @IBOutlet weak var myLabel:UILabel! var label = "" override func viewDidLoad() { super.viewDidLoad() self.myLabel.text = self.label } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } */ }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/18 05:03