Auk icon indicating copy to clipboard operation
Auk copied to clipboard

Slider not showing it self when you try to add 3 images or more

Open 0xjorgev opened this issue 6 years ago • 4 comments

  • Library setup method: CocoaPods
  • Version of the library. Example: 8.0.
  • Xcode version. Example: 9.2.
  • OS version. Example: iOS 11.2.

Hi there!, first of all thanks for this amazing software component, i'd used moa in the past and Auk it's a very elegant solution for image sliders for the iOS platform!.

My issue goes like this:

I am using Auk to add an image slider as a tableView Header, in a project that doesn't use Storyboards, for that porpoise i had created a separated class with all the needed setup:

` import UIKit import moa import Auk

class CategoryNecessitiesTableViewHeader: UIView, UIScrollViewDelegate {

var scroll:UIScrollView?

var contentInnverView:UIView?

override init(frame: CGRect) {
    super.init(frame: frame)
    createViews()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

func createViews(){
    Moa.logger = MoaConsoleLogger
    self.scroll = UIScrollView()
    self.contentInnverView = UIView()
    self.scroll?.delegate = self
    
    self.scroll?.auk.settings.showsHorizontalScrollIndicator = true
    self.scroll?.auk.settings.pageControl.visible = true
    self.scroll?.auk.settings.pagingEnabled = true
    self.scroll?.auk.settings.pageControl.backgroundColor = UIColor.gray.withAlphaComponent(0.3)
    self.scroll?.auk.settings.pageControl.currentPageIndicatorTintColor = .appBlue
    self.scroll?.auk.settings.pageControl.pageIndicatorTintColor = .gray
    self.scroll?.auk.settings.pageControl.backgroundColor = .clear
    self.scroll?.auk.settings.contentMode = .scaleAspectFill
    self.scroll?.auk.settings.preloadRemoteImagesAround = 1
    self.scroll?.auk.settings.placeholderImage = UIImage(named: "empty_just")
    self.scroll?.auk.settings.errorImage = UIImage(named: "empty_just")
    
    if #available(iOS 11.0, *) {
        self.scroll?.contentInsetAdjustmentBehavior = .always
    }
    
    self.contentInnverView?.addSubview(self.scroll!)
    self.addSubview(contentInnverView!)
    setupConstraints()
}

func setup(images:[String]?){            
        self.scroll?.auk.removeAll()
        if let imgs = images {
           _ = imgs.map{ scroll?.auk.show(url: $0) }
      }
}

func setScrollImages(images:[String]?) {
    self.scroll?.auk.removeAll()
    _ = images.map{ $0.map{ scroll?.auk.show(url: $0) }}
}

func setupConstraints(){
    let size = CGSize(width: UIScreen.main.bounds.width, height: 250.0)
    let sizeSmaller = CGSize(width: UIScreen.main.bounds.width, height: 210.0)
    self.autoSetDimensions(to: size)
    self.contentInnverView?.autoSetDimensions(to:sizeSmaller)
    self.scroll?.autoPinEdgesToSuperviewEdges()
}

} `

The thing is if i send one or two images the slider works perfect, it shows loads the images, shows the pager controller and the world is a happy place, how ever if i send an array o 3 or more images it simply shows nothing in the screen, Thanks before hand!!

0xjorgev avatar Apr 02 '18 10:04 0xjorgev

Hi, thanks for reporting. This is weird indeed. Honestly, I have no idea why it does not show 3 images. I would try commenting everything except the most important stuff, in order to isolate the problem.

evgenyneu avatar Apr 02 '18 12:04 evgenyneu

@evgenyneu thanks for your fast response, in order to avoid any other kind of issues i'll try to isolate my class with the AUK implementation and test it in a empty project, this really took me a bunch of hours to figure this out!, i'll get back to you with this "clean" project to see it the weird behavior persists

0xjorgev avatar Apr 02 '18 15:04 0xjorgev

@evgenyneu as promised, here is a simple project that shows the weird behavior, thanks in advance for your time, i really love this project AUK-Bug.zip

0xjorgev avatar Apr 08 '18 18:04 0xjorgev

Thanks for that code, @jorgevmendoza. I think the problem was to do with the layout of the views.

  1. I've commented the function setupConstraints and wrote a new one called layoutViews. This fixed the issue with images.

  2. I've also commented the call to self.scroll?.contentInsetAdjustmentBehavior = .always, since it made the scroll view scroll vertically a little bit, which was not expected.

AUK-Bug-updated.zip

Let me know if it helps. :)

evgenyneu avatar Apr 14 '18 01:04 evgenyneu