【发布时间】:2017-12-05 08:14:49
【问题描述】:
当用户使用 DKImagePickerController github 选择图像时,我想在滚动视图上显示多个图像。 这是我的代码,但没有出现图像。任何人都可以告诉什么是错的? 提前谢谢!
var picker = DKImagePickerController()
var imagesArray = [Any]()
@IBAction func pickPhoto(_ sender: Any) {
picker.maxSelectableCount = 10
picker.showsCancelButton = true
picker.allowsLandscape = false
picker.assetType = .allPhotos
self.present(picker, animated: true)
picker.didSelectAssets = { (assets: [DKAsset]) in
self.imagesArray.append(assets)
for i in 0..<self.imagesArray.count {
let imageView = UIImageView()
imageView.image = self.imagesArray[i] as? UIImage
imageView.contentMode = .scaleAspectFit
let xposition = self.view.frame.width * CGFloat(i)
imageView.frame = CGRect(x: xposition, y: 330, width: self.scrollView.frame.width, height: 170)
self.scrollView.contentSize.width = self.scrollView.frame.width * CGFloat(i * 1)
self.scrollView.addSubview(imageView)
}
}
}
【问题讨论】:
标签: ios swift xcode uiscrollview