在我的班级中,在保存拾取的图像后,我正在尝试设置变量值,但它不会改变。
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
let imageName = Util.generateFilename(activityId.integerValue)
var localPath = Util.getExpensePath(activityId.stringValue)
localPath = localPath?.URLByAppendingPathComponent(imageName, isDirectory: false)
let image = Util.reduceImageSize(info[UIImagePickerControllerOriginalImage] as! UIImage, compressionQuality: 0.5)
let data = UIImagePNGRepresentation(image)
data!.writeToFile(localPath!.path!, atomically: true)
picker.dismissViewControllerAnimated(true, completion: nil)
imagePickedPath = localPath!.path!
}
@IBAction func viewButtonClick(sender: UIButton)
{
showImage(imagePickedPath!)
}
调试,imagePickedPath似乎在第一个方法执行最后一行后改变了值但是当我点击查看按钮时,imagePickedPath继续具有旧值。怎么了?