Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0xjorgev opened this issue Apr 2, 2018 · 4 comments
Open

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

0xjorgev opened this issue Apr 2, 2018 · 4 comments

Comments

@0xjorgev
Copy link

0xjorgev commented Apr 2, 2018

  • 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!!

@evgenyneu
Copy link
Owner

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.

@0xjorgev
Copy link
Author

0xjorgev commented Apr 2, 2018

@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
Copy link
Author

0xjorgev commented Apr 8, 2018

@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

@evgenyneu
Copy link
Owner

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants