Giter Club home page Giter Club logo

Comments (6)

 avatar commented on June 23, 2024

I made this public in a local version but found it often returned nil so eventually coded an alternate method which satisfied my needs using the vanilla API.

This is probably why the method isn't public from the outset, as there are clearly certain caveats regarding its use which aren't currently documented.

from icarousel.

nicklockwood avatar nicklockwood commented on June 23, 2024

Yep, I agree, and in fact this is already included for 1.5.5 (not yet released)

Nick

(Sent from my iPhone)

On 15 Aug 2011, at 14:23, sgabello [email protected] wrote:

I'm already doing it in my fork because I need to show/hide the current view... But generally speaking I find it a useful method to expose to everyone... What you think?

Reply to this email directly or view it on GitHub:
https://github.com/demosthenese/iCarousel/issues/31

from icarousel.

nicklockwood avatar nicklockwood commented on June 23, 2024

Added in 1.5.5, but it's called - (UIView *)itemViewAtIndex:(NSInteger)index for consistency

from icarousel.

 avatar commented on June 23, 2024

Does this new method load the view before returning it if it isn't already loaded, to avoid returning nil as it's counterpart does?

from icarousel.

nicklockwood avatar nicklockwood commented on June 23, 2024

It returns nil. I thought about triggering the load in that situation, but it's not really useful.

The main reason for the method is so you can manipulate visible views in the carousel. Every time a view is loaded, a new instance is created, so loading a view that's not visible in the carousel would be pointless because it it would never get displayed - as soon as it moved into view, a new instance would get loaded anyway. Any manipulation you did to it would be wasted.

If for some reason you do want a view that's not been loaded, just call the dataSource method for it yourself, e.g.

UIView *itemView = [carousel itemViewAtIndex:index];
if (itemView == nil)
{
    itemView = [carousel.dataSource carousel:carousel viewForItemAtIndex:index];
}

from icarousel.

 avatar commented on June 23, 2024

Ah, okay. Thanks for providing some interesting clarification.

I was unaware a new view would be created each time it becomes visible, and this certainly clears up some unintended issues I've run into :)

It also explains the slow down/jerkiness which affects scrolling when I lower numberOfVisibleItems from its default to say eleven, as it is having to load, discard and reload views more often.

from icarousel.

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.