sender.setBackgroundImage(imageArray[index], forState: .Normal)
sleep(2) // wait before you flip back over
sender.setBackgroundImage(cardBack, forState: .Normal)
睡眠似乎阻止图像完成其负载。我如何等待setBackgroundImage
完成?
答案 0 :(得分:0)
sender.setBackgroundImage(imageArray[index], forState: .Normal)
sender.enabled = false;
let delay_time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), 2 * Int64(NSEC_PER_SEC))
dispatch_after(delay_time, dispatch_get_main_queue()) {
sender.setBackgroundImage(cardBack, forState: .Normal)
sender.enabled = true;
}
编辑:在显示图片时禁用该按钮。