Я пытаюсь создать imageView карусель с помощью PageControl в titleView. Теперь все работает, помимо выравнивания изображений. Что я здесь делаю неправильно? Посмотрите на нижнее изображение, где оно, похоже, не подходит для всего этого?UIImageView и ScrollView странное поведение
Cell
class ImageViewCell: UITableViewCell, UIScrollViewDelegate {
@IBOutlet var imageScroll:UIScrollView?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
//scrollView
imageScroll!.backgroundColor = UIColor.blackColor()
imageScroll!.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
imageScroll!.showsHorizontalScrollIndicator = false
imageScroll!.showsVerticalScrollIndicator = false
imageScroll!.pagingEnabled = true
imageScroll!.contentMode = UIViewContentMode.Center
imageScroll!.bounces = false
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
CellForRowAtIndexPath в ViewController
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ImageCell", forIndexPath: indexPath) as! ImageViewCell
cell.imageScroll!.contentSize = CGSizeMake(self.view.frame.width * CGFloat(pageImages.count), 200)
cell.imageScroll!.delegate = self
for (index, element) in pageImages.enumerate() {
let newImage = UIImageView(frame: CGRectMake(CGFloat(index) * self.view.frame.width + 4, 0, self.view.frame.width, 200))
newImage.image = element
cell.imageScroll!.addSubview(newImage)
}
return cell
}
возможно, '+ 4' на позиции' UIImage' x? –
oops yea, но не удаляет все. он находится на обоих изображениях –