【发布时间】:2016-06-13 00:34:53
【问题描述】:
我有一个滚动视图,其中包含我从网上下载的一些图像。我将这些图像添加到滚动视图中,但在它们之间添加黑色空间时遇到问题。它们处于垂直滚动而不是水平滚动中。我一直在考虑尝试添加一个空间,但不知道该怎么做。任何帮助,将不胜感激。 这是我到目前为止所拥有的;
private func loadImages() {
myImages = 0;
ImageManager.sharedInstance.getAllImagesFromServer({
promotions in
for (_,promotion) in promotions {
Utility.log(self.dynamicType, msg: promotion.picture, function: "viewDidLoad")
self.downloadImage(NSURL(string: promotion.picture)!)
}},
onFail: { error_code, detail in Utility.log(self.dynamicType, msg: "Get All Iamges Fail, error_code: \(error_code), detail: \(detail)",
function: "viewDidLoad")})
}
func getMyImage(url: NSURL){
getDataFromUrl(url) { (data, response, error) in
dispatch_async(dispatch_get_main_queue()) { () -> Void in
guard let data = data where error == nil else { return }
print(response?.suggestedFilename ?? "")
let imageView = UIImageView(image: UIImage(data: data));
imageView.frame = CGRect(x: 0,
y: Int(self.myImages * 200), width: Int(self.myScrollView.frame.size.width), height: 200)
self.myScrollView.addSubview(imageView)
self.myImages = self.myImages + 1;
self.myScrollView.contentSize = CGSizeMake(self.myScrollView.frame.size.width,
CGFloat(self.myImages * 200));
}
}
}
【问题讨论】:
-
只需创建每个帧的
y值。
标签: ios uiscrollview uiimageview