evgenyneu / Auk

An image slideshow for iOS written in Swift.
MIT License
278 stars 44 forks source link

have a blank on the top #5

Closed oscar608 closed 8 years ago

oscar608 commented 8 years ago

11111

oscar608 commented 8 years ago

222222

evgenyneu commented 8 years ago

Hi, try explaining your case in more words please. It is hard for me to see what is the problem and what can be causing it.

oscar608 commented 8 years ago

image

oscar608 commented 8 years ago

in iphone 6 is ok

oscar608 commented 8 years ago

the view controller have a tableview,and i add a UIScrollView as the tableview header by the follow code:

 @IBOutlet weak var scrollView: UIScrollView!

@IBOutlet weak var tableView: UITableView!

override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = Util.getBackgroundColor()
        self.automaticallyAdjustsScrollViewInsets = false

        let frame = CGRectMake(0, 0, self.view.frame.size.width, 150)
        scrollView.frame = frame

        scrollView.auk.settings.errorImage = UIImage(named: "icon_sj_me.png")

        scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/11.png")

        scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/22.png")

        scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/33.png")

        scrollView.auk.settings.contentMode = UIViewContentMode.ScaleAspectFill

        // Set background color of page indicator

        scrollView.auk.settings.pageControl.backgroundColor = UIColor.grayColor().colorWithAlphaComponent(0.3)

        scrollView.auk.startAutoScroll(delaySeconds: 3)

         self.tableView.tableHeaderView = scrollView

    }
oscar608 commented 8 years ago

and then in iphone 6 is ok, but in iphone 4 and iphone 5 have a blank on the top:

image

evgenyneu commented 8 years ago

I have done two things to make it work:

  1. Use scrollView.auk.settings before showing images (setting UIViewContentMode.ScaleAspectFill).
  2. Assign the scroll view to table view header before showing images.

Hope it helps

Code example

func createScrollView() {
    let scrollView = UIScrollView()
    scrollView.backgroundColor = UIColor.greenColor()
    scrollView.auk.settings.contentMode = UIViewContentMode.ScaleAspectFill // Set before showing images

    self.view.backgroundColor = UIColor.yellowColor()
    self.automaticallyAdjustsScrollViewInsets = false

    let frame = CGRectMake(0, 0, self.view.frame.size.width, 150)
    scrollView.frame = frame
    self.tableView.tableHeaderView = scrollView // Set scroll view before showing images

    scrollView.auk.settings.errorImage = UIImage(named: "icon_sj_me.png")

    scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/11.png")

    scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/22.png")

    scrollView.auk.show(url: "http://7xljm5.com2.z0.glb.qiniucdn.com/33.png")

    // Set background color of page indicator

    scrollView.auk.settings.pageControl.backgroundColor = UIColor.grayColor().colorWithAlphaComponent(0.3)

    scrollView.auk.startAutoScroll(delaySeconds: 3)
  }

Demo app

AukDemo.zip

oscar608 commented 8 years ago

goood!!!!! it is ok now,Thank you very much!!!~~~~