非常に奇妙なエラーが発生しています。コンパイラは、現在のビューコントローラのすべてのコードを実行するまで、別のビューコントローラにセグをすることはできないと私に伝えようとしていますが、わかりません。1つのビューコントローラから別のビューコントローラに「セグリング」するときに奇妙な警告が表示される
アラートボックス(つまり、generateTextField
という名前の関数を呼び出す)を使用して文字通り入力を取得しています。
私がやったとき、私はあなたが別のビューコントローラーに行きたがっていると言っていますが、コンパイラーは代わりに "ちょっと私はそうは思わない"と言います。ここで
は私のエラーです:
警告:HairStyle1ViewControllerを提示しようとしていますを0x7 ...> browseBarbersViewController上:を0x7 ...>すでに 警告提示している:HairStyle1ViewControllerを提示しようとしていますを0x7を.. > browseBarbersViewControllerに:を0x7 ...>すでに
@IBAction func AddNewStyleButtonClicked(sender: AnyObject)
{
// Get the "hairstyle name" from the user
generateTextField();
// OK We are done with that function, now transition to the
// next screen
performSegueWithIdentifier("HairStyle1", sender: self);
}
// Generate a text field for user input (i.e. call the alert function)
func generateTextField()
{
//1. Create the alert controller.
var tempStyle = "";
var alert = UIAlertController(title: "Add a New Style", message: "Enter the name of the new hairstyle below", preferredStyle: .Alert);
//2. Add the text field. You can configure it however you need.
alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in
textField.placeholder = "Your New Hairstyle Goes Here..";
})
//3. Grab the value from the text field, and print it when the user clicks OK.
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in
let textField = alert.textFields![0] as UITextField
tempStyle = textField.text!;
print("New Style Added is: " + tempStyle);
HairStyle = tempStyle;
}))
// 4. Present the alert.
self.presentViewController(alert, animated: true, completion: nil)
}
を提示しているそれは私がgenerateTextField()
機能を取るとき、それはセグエを完全に実行することも奇妙です。私は非常に混乱しています。
は、はい、私はそれをチェックし、勇者はそれが正常に動作しますポイント.followそれが正常に動作した後、私は
を追加することによって、これを修正しました。 –