0
我試圖將按鈕移動到另一個按鈕的單擊位置。這是我的viewcontroller中的代碼。將按鈕移動到隨機位置(Swift)
@IBOutlet weak var samea: UIButton!
@IBAction func yup(sender: UIButton) {
let buttonWidth = samea.frame.width
let buttonHeight = samea.frame.height
let viewWidth = samea.superview!.bounds.width
let viewHeight = samea.superview!.bounds.height
let xwidth = viewWidth - buttonWidth
let yheight = viewHeight - buttonHeight
let xoffset = CGFloat(arc4random_uniform(UInt32(xwidth)))
let yoffset = CGFloat(arc4random_uniform(UInt32(yheight)))
samea.center.x = xoffset + buttonWidth/2
samea.center.y = yoffset + buttonHeight/2
// Do any additional setup after loading the view, typically from a nib.
}
}
我簡單地爲我想要移動的按鈕創建一個插座,然後爲移動它的按鈕創建一個插件。當我運行這個時,它在啓動時發生線程1:信號SIGABRT錯誤時崩潰。我該如何解決?
你能給我們更多的錯誤輸出嗎?這還不夠。 –
下面是錯誤的imgur鏈接:http://imgur.com/a/BFSfV – Ash
看看左下方的框裏有什麼?我們需要看到這一點。這是我們將看到錯誤輸出的地方。 –