2つの画像を持つプログラムをコーディングしようとしました。私は1つの画像を移動するために4つのボタンを上下左右に使います。 そのイメージが他のイメージに到達すると、テキストフィールドが表示されます: "あなたは優勝者です!"Swiftの "期待される宣言"
ただし、If ...というコードを含む行には常に "Expected Declaration"エラーが発生します。どのように私はそれを実行することができます、pls?
これは、全体のコードで、2枚の画像の名前がConChimCuとチュンです:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var txtBai: UITextView!
@IBOutlet weak var ConChimCu: UIImageView!
@IBOutlet weak var Trung: UIImageView!
@IBAction func Up(sender: AnyObject) {
ConChimCu.frame.origin.y = ConChimCu.frame.origin.y - 2
}
@IBAction func RIGHT(sender: AnyObject) {
ConChimCu.frame.origin.x = ConChimCu.frame.origin.x + 2
}
@IBAction func DOWN(sender: AnyObject) {
ConChimCu.frame.origin.y = ConChimCu.frame.origin.y + 2
}
@IBAction func LEFT(sender: AnyObject) {
ConChimCu.frame.origin.x = ConChimCu.frame.origin.x - 2
}
if ConChimCu.frame.origin.x == Trung.frame.origin.x { txtBai.text = "You are the winner!"
}
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.
}
可能な重複のXcode 6.2使用スウィフト](http://stackoverflow.com/questions/29835490/expected-declaration-error-xcode-6-2- swift) – vadian