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

Not really an issue... more a suggestion: make "- (UIView *)viewAtIndex:(NSInteger)index;" public... #31

Closed
sgabello opened this issue Aug 15, 2011 · 6 comments

Comments

@sgabello
Copy link

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?

@ghost
Copy link

ghost commented Aug 15, 2011

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.

@nicklockwood
Copy link
Owner

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 reply@reply.github.com 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

@nicklockwood
Copy link
Owner

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

@ghost
Copy link

ghost commented Aug 16, 2011

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?

@nicklockwood
Copy link
Owner

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];
}

@ghost
Copy link

ghost commented Aug 16, 2011

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.

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