Giter Site home page Giter Site logo

How to update pageIndex? about auk HOT 6 CLOSED

evgenyneu avatar evgenyneu commented on August 17, 2024 1
How to update pageIndex?

from auk.

Comments (6)

evgenyneu avatar evgenyneu commented on August 17, 2024 1

Hi @Darwinium, good quesion. In order to update a label with the current page number one needs to detect the moment when user scrolls the scroll view. It can be done by implementing a scroll view delegate with the scrollViewDidScroll method:

  1. Firstly, subclass your view controller from UIScrollViewDelegate:
class ViewController: UIViewController, UIScrollViewDelegate {
  1. Secondly, assign the view controller to the delegate property of the scroll view. Make sure to assign the delegate before accessing scrollView.auk property.
override func viewDidLoad() {
    super.viewDidLoad()

    scrollView.delegate = self
    scrollView.auk.show(...
  1. Finally, implement scrollViewDidScroll method in your view controller. In this method you can update your label with the index of the current page.
func scrollViewDidScroll(scrollView: UIScrollView) {
   imageIndex.text = String(scrollView.auk.currentPageIndex)
}

Good luck and let me know how it goes.

from auk.

Darwinium avatar Darwinium commented on August 17, 2024

Hi again, evgenyneu

Thanks, it's work!

Few more questions:

  1. How can I bind the picture to the bottom of UIScrollView regardless of the size of the image?
    Example how's now:
    http://joxi.ru/krDkgY1T0z09KA
    http://joxi.ru/eAO6EP0h4j4ej2
  2. How can I do something like this? http://joxi.ru/Q2KqgPDH9J9Q8r

Thank you again and have a nice day)

from auk.

evgenyneu avatar evgenyneu commented on August 17, 2024

No worries. Sorry I do not understand your question. Can you explain a bit more? Do you want to show a part of the next image in the scroll view?

from auk.

Darwinium avatar Darwinium commented on August 17, 2024

Exactly!

from auk.

evgenyneu avatar evgenyneu commented on August 17, 2024

Hi @Darwinium, unfortunately Auk only shows a single image at a time. But you can create such image view that shows a portion of the next image yourself. Here is a demo: https://github.com/evgenyneu/SneakPeekScroll

from auk.

evgenyneu avatar evgenyneu commented on August 17, 2024

Closing this issue. Feel free to reopen when needed.

from auk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.