nicklockwood / icarousel Goto Github PK
View Code? Open in Web Editor NEWA simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
Home Page: http://www.charcoaldesign.co.uk/source/cocoa#icarousel
License: Other
A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
Home Page: http://www.charcoaldesign.co.uk/source/cocoa#icarousel
License: Other
I just started using iCarousel and it's wonderful. I'm using the custom transformer you provided to get a stacked window (or deck of cards) effect. Is there a way to remove the drop-shadow effect that appears at the bottom of the carousel? I've tried the various offsets, etc. Setting ClipsToBounds doesn't quite do it (but does minimize it because of the canted perspective I still get a shadow on the right bottom of the view.
Thanks for the great work.
George
Dear Nick,
I'd like to add sound effect to the carousel (ticking sound while scrolling). Could you please tell me how? Thanks.
Hi,
i have a problem with iCarousel on iPad.
My project works great on simulator, but on devices (iPad 1 or 2) carousel view is empty.
View has been created and touch recognized, but image and action are not be available.
How can I solve this problem?
This is my code (I download the last version).
Thanks in advance. Bye.
.H
iCarousel *carousel;
.M
(void)viewDidLoad {
[super viewDidLoad];
carousel.type = iCarouselTypeRotary;
[self.carousel reloadData];
}
Hi,
is there a good way to obtain the same effect of coverflow in the iPod iOS app? I've tried different solutions using core animation but all of them seemed "dirty" and with some collateral effects.
Unless I set: view.userInteractionEnabled = NO;
- (void)transformItemViews
{
//lay out items
for (NSUInteger i = 0; i < numberOfItems; i++)
{
UIView *view = [itemViews objectAtIndex:i];
[self transformItemView:view atIndex:i];
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
view.userInteractionEnabled = NO; //(i == self.currentItemIndex);
#endif
}
Any suggestion?
The timer in -setup retains its target (self) which has as effect that the -dealloc method will never be reached as there is always the timer retaining the iCarousel instance. Adding the method below fixes this.
- (void)willMoveToSuperview:(UIView *)newSuperview {
if (!newSuperview) {
[timer invalidate], timer = nil;
} else if (!timer) {
timer = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(step) userInfo:nil repeats:YES];
}
}
I am not sure if I'm missing something or it's a feature not implemented:
I have a carousel that uses two different item-sizes for portrait and landscape, with the langscape size being smaller.
Therefore, all items shrink in landscape mode. At the moment I call layoutSubviews
and reloadData
and in didRotateFromInterfaceOrientation
.
Unfortunately, this leads to gaps between the items when rotating the device from portrait to landscape, as the subviews do not seem to be rearranged with the new item size (their anchor point just stays where it was).
So does the component not yet support a variable item size? And if it does, what's the right order of calling layoutSubviews
etc.?
Or is the (animated) change of the item size currently not possible?
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?
Hi! Thanks for this project, i like it!
I have a question! Is it possible to change the size of the Coverflow items?
Does exist a way to hide placeholder and show them (make them visible) after I get all source for carousel
(because I download them from internet)
thanks
Paolo
Hello,
first of all, amazing work! I was able to use the carousel immediately. Thank you!
I have 2 questions:
Again, thank you for this great work.
lx
setup:
added 6 items
all visible on the screen at the same time
enabled infinite scrolling
when u scroll all the way round from the first item back to the first item. Scrolling to the left(does not happen to the right). once u rech the first item again it does a full loop.
thx
I've added iCarousel using IBOutlet approach. Width of the view is - 924 and style I am using is Linear. I am noticing that when I scrolling, content going outside of the given view.
I gone through the documentation but couldn't find any reference to property that can fix this issue.
How would I fix this issue?
Thanks ,
Amit
when i add the codes bellow,
carousel.viewpointOffset = CGSizeMake(300,0)
the presentation of iCarousel is strange.
Hi
Amazing library.
I have a problem where I need to use the cylinder type carousel, with quite a wide spacing, but with a dataset of at least 200 images, maybe going into the thousands.
I need to use the cylinder because of all of them it has the most affordance for swiping for non iOS friendly users.
However, I don't need the ones at the rear of the carousel to show all of them - therefore making the diameter of the cylinder larger than it is with just the sample demo size of 21, but I do need that an item gets to the very back, it doesn't start to come back around until it really should.
Not sure if I'm being clear enough, but lets say the cylinder holds 21 visible items the one at the back left is 21 and the one to it's immediate right is number 1 - i.e. it's wrapping and we're probably looking at 10 or 11 at the 'front'.
However, with a large data set of 1000, if I'm looking at 500 at the front, the rear left will be 511 and the rear right will be 489, so with the next swipe to the left, the rear left will be 512 and the right right will be 488... but regardless of the size of the data set, the diameter of the 'cylinder' is fixed.
Is this possible without a huge re-write of the icarousel.m code? Or have I missed the forrest for the trees and it's must more simple and elegant?
Thanks so much for this library (and your others) and I hope you find the time to help with this question.
Regards
Zoe
Hi Demosthenese,
On launching the iOS demo there is an exception thrown on an unrecognized selector:
-[iCarouselExampleViewController carousel:placeholderViewAtIndex:]
This is an optional method that is not implemented in the demo. In iCarousel.m reloadData I replaced that call with this:
[dataSource carousel:self viewForItemAtIndex:i]
As far as I can tell the demo works perfectly now. I hope this helps, I don't really know the proper process for reporting issues.
The commit id for the version I just pulled today (July, 8, 2011) is "fa482e206fafab8e7e8c"
error: assigning to property with 'readonly' attribute not allowed [3]
in v. 1.5.2 this was no issue, could you please fix that?
In linear mode initialize the item on the left, and when scroll to the end, the last item has stopping on the right of the view.
Currently, the first and last always stop in the center.
Its possible?
In the method insertItemAtIndex:animated (line 973), the first 2 lines should be swapped. We should therefore have:
numberOfItems ++;
index = [self clampedIndex:index];
Otherwise, when inserting a new item at the end of the list, it's view would be the view of the item just before it. As the method clampledIndex: doesnt allow the new last item index.
Hi Nick !
Some bugs I came across.
1-/ In the demo app, choose the carousel type linear, non-wrap. Then delete all items with the delete button. You'll then see only the placeholders. Then simply insert an item with the appropriate button. SIGABRT crash.
2-/ I have another bug, I'm not sure it's related to the previous one.
When I load my app, the carousel is empty. (linear type, no-wrap).
Then the user can add an item and it ends up in the carousel, so I call the insert method. The new item is added as expected but it's not centered, looks like it holds the position 2. I have to call reload data to make it work.
3-/ Also, when an item is added at position X, I add it to that position in the carousel and then call scrollToIndex with X as parameter : nothing happens, it won't scroll.
Let me know if you need more details.
Thanks !
If you configure your carousel to be of the linear type and set wrapping to NO
, your first and last item also is centered in the view. This results in empty space on the left (first item) and right (last item).
Is it possible to configure the carousel so that when you are at item-index 0, the first item will be at the very left of the view, and vice versa that the carousel ends with the last item being on the very right? Or does that just conflict with the scrollOffset
-property?
Hello,
It would be very useful if there were an option to detect when the user tapped or double-tapped a certain item in the Carousel.
Thank you very much!
Hi,
Your project is superb. But I want to have multiple iCarousel in single UIView.
They point to different array of contents.
In the delegate methods of your API how to support this scenario?
Any help would be appreciated.
Thanks
Hi, first of all thanks for your amazing code!!
One question: when I use cylindrical effect with few items, I notice a "bad" fragment effect on the image border.
Is there a method for avoid aliasing effect on 2D rotating images?
Regards
GF
P.S. Little suggest: in next release you could add an "opacity" effect for far objects, specially for cylindrical effect.
Hey Nick,
This is actually one of the best opensource things for iOS, better then Three20 or whatever, very very very easy to use and just lovely.
there is just one thing bugging me actually. That the Carousel isn't respecting the bounds of it's view within a nib.
So if you create lets say an UIView with iCarousel as parent in a xib on a ViewController. And you make it half of iPad screen.
That when it gets loaded, they are over the border of what you tell them to stay in, is it me, am I missing something, or no one actually cared about this? :)
Greetings, Noxx.
I dont see any method permitting to reload a single item; something like reloadViewAtIndex: (which would then call the delegate method to fetch the view at that index).
Am I missing something ?
Thanks!
Hi Nick,
Iam using I iCarousel as a linear type with wrap Off to display a carousel menu at the top of my view.
The menu items in this view are taken from a server response. So whenever I get new data from the server, I update my model
and call iCarousel reloaddata. The problem is sometimes even though I get the proper data and my model is updating properly ,
after the reload icarousel fails to display anything. Iam not using any placeholders and the no of visible items are no of items in my menu. Here is the code where Iam doing this:
The interesting thing is when I rotate the orientation , then it gets loaded properly ( layoutSubviews is called when the orientation is changed) and it occurs only on device, not on simulator
(void)onGettingCatagoryData:(NSArray *)array
{
if(m_categoryArray)
{
[m_categoryArray release];
m_categoryArray = nil;
}
// m_categoryArray = [[NSMutableArray alloc] init];
m_categoryArray = [array mutableCopy];
[m_categoryArray insertObject:m_allDictionary atIndex:0];
NSArray *otherArray = [[SmartClientFWBase sharedSmartClientFWBase] getRootWidgets:NO];
if([otherArray count])
[m_categoryArray insertObject:m_othersDictionary atIndex:([array count] + 1)];
[self creatingButtonsForCarousel:[m_categoryArray count]];
[self.icarousel reloadData];
[self.icarousel scrollToItemAtIndex:0 animated:YES];
}
and here is my viewAtindex method:
(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
return [m_buttonArray objectAtIndex:index];
}
m_buttonArray is a mutable array created only once and updated in creatingButtonsForCarousel which is called in the above method
Would appreciate any sort of help..
Thanks
Vamshi
I'm trying to use carousel:shouldSelectItemAtIndex: in my delegate and I'm finding that it isn't being called. I think I've tracked down the problem - what's happening is that the carousel adds my item view to its list, then calls containView: to wrap my item view in a container, and sets up a gesture recogniser for the container. Then in gestureRecognizer:shouldReceiveTouch: the touch parameter's view is the container, which isn't in the carousel's list, so indexOfView: returns NSNotFound and carousel:shouldSelectItemAtIndex: isn't called.
I'm not sure what the best way of fixing this would be - perhaps the carousel needs to be able to recognise its container views?
Hi Nick,
Can you please help me in my problem?
I have couple of views and width of one of this view smaller than other. How can I set width of this view for linear carousel type?
Thanks
when i call reloadData... old carousel views remain in view behind the new views
Hey Nick,
You've been a great help before.
But this is the first time I'm actually having some issues.
I just did what I allways did..
Changed the view to iCarousel, did the clip subviews.
Started populating in the initWithCoder like this..
(id)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
wrap = NO;
devoObjects = [[NSMutableArray alloc] init];
[self loadDevoObjects];
items = [[NSMutableArray alloc] init];
for (int i = 0; i < [devoObjects count]; i++)
{
[items addObject:[NSNumber numberWithInt:i]];
}
}
return self;
}
After the viewForItemAtIndex is called, also correctly, it shows me what I want, but when it's done loading them all. I get above error ^
On line 1261.
First time I had this, does it have to do with me calling other animations at same time, because the view is sliding in etc.. I even tried without, but it's giving me same stuff. I tried with 3 several builds I have of your project, but nothing.
Could you get back to me please :)
Greetings, Noxx
Hi,
I modified iCarousel little bit like i have some 5 buttons in my view watch time on click of a particular button the NUMBER_OF_ITEMS count will change and i am calling reloadData and wrap = YES; and i'm using iCarouselTypeCoverFlow carousel type then
once if i start panning everything is ok.
My question is is it possible to make start the index as 0,1,2 pattern or 0,1 pattern for all the counts, i mean i need a constant pattern each time when i reload.
Since reloadData is called in
reloadData gets called on my iCarousel 5 times (because I also do a reloadData in viewWillAppear) right after creation. Maybe you should defer calling reloadData until everything is set up (at least dataSource) ?
Hi,
I found that carousel with type iCarouselTypeRotary is not displaying properly when only two images are loaded. The images are rendered on top of each other.
Regards
Andrius
Hi, in my project the method viewForItemAtIndex not called.. this is the simple code:
(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//[carousel reloadData];
carousel.type = iCarouselTypeRotary;
}
and in IB is all ok!
I tried to reloadData but nothing happened...
I'm doing a universal app with xcode 4.2 for iOs > 3.2
Is there a way to revert this back to the bouncing the carousel previously did?
Hi,
I am loading a large list of imageviews to carousel like this:
Where Globals is my singleton class.
All images are png files stored in the Documents folder. No transformations or additional drawing is performed. All images' size is 300 x 300 pixels.
I am using 19 in numberOfVisibleItemsInCarousel which loads the carousel almost instantly.
The scrolling of carousel is swift in the iPad simulator, but there is a very slight (but noticeable) lag when performing fast swipes on the actual device. I am using the rotary type by the way.
I was wondering if implementation of loading of unallocated views into the visible array on the background thread would help eliminate this lag?
Also, since I'm quite new to Xcode, I would very much appreciate if someone would share a snippet of this implementation if there is one.
Thanks and kind regards,
Andrius
can make a vertical carousel? Linear... or Rotatory
Hi,
I found problem with method "scrollToItemAtIndex:animated: ".
on iOS code, I call this method with an index and animated NO argument.
But it doesn't scroll to the index .
like this:
[carousel scrollToItemAtIndex:4 animated:NO] // not scroll, it'll appear index 0.
And I tried to replace duration 0 with 0.01 on scrollToItemAtIndex:duration: method.
It seems works well.
Is this bug or not ?
thanks.
Can you make a transform to have this kind of carousel?
http://stackoverflow.com/questions/8315846/ios-fan-style-carousel
Or give me some clues how to do it.
Thanks.
If the iPhone example project, I can't get the buttonTapped method to fire. I can confirm the UIButtons are being created, but it seems the gesture recognizer steels the event. This isn't very critical as the events to flow through to the didSelectItemAtIndex method, but it would be nice if the UIButton worked as expected.
BTW - this is a very useful class. Thank you for sharing it.
on carouselDidEndScrollingAnimation delegate method, i couldnt make uiview animate. View object jumps to destination but it works fine with delay call. I tryed to explain problem blow, any idea what would cause it?
Thanks in advence.
- (void) makeAnim{
[UIView beginAnimations:nil context:i];
[UIView setAnimationDuration:0.5];
navigation.frame = CGRectOffset(navigation.frame, 0, 430);
[UIView commitAnimations];
}
- (void) carouselDidEndScrollingAnimation:(iCarousel *)carousel{
//[self makeAnim]; // this method doesnt work here. But its fine with the hack below.
// Ugly hack
[self performSelector:@selector(makeAnim) withObject:nil afterDelay:0.0001];
}
Hey,
This isn't so much an issue, more seeking advice on how best to optimise iCarousel for use with large datasets.
I have an iCarousel set up in iCarouselTypeLinear
mode that displays three 128x128 views at a time on screen. I'm currently returning 11 from numberOfVisibleItemsInCarousel:
. Depending on the current scenario numberOfItemsInCarousel:
can return a number anywhere between 50 and 700.
The view I return in viewForItemAtIndex:
was initially very simple in that in it's drawRect:
method it did nothing more than create a path, clip the context to that path and then draw an image from a property which is set when the view is created. This worked great when the dataset was small. However with large datasets the scrolling started to lag somewhat so I implemented a new delegate method that passes the view about to be disposed by iCarousel when it's off screen. I add that view to an array so it acts as a view cache. Now in viewForItemAtIndex:
I first check to see if there is a view available in the cache, and if there is I return that instead of creating a new one. This means that I'm never creating more than 11 views. Before returning I reconfigure the properties, the main one being the image. The issue with this is that I then need to call setNeedsDisplay
on the view to force it to redraw and display the new image. This again caused a lag in the scrolling. To try and resolve it I switched to use a CALayer and add the image as the contents instead of drawing directly to the view. This has reduced but not eliminated the lag.
Therefore, based on what I've outlined above, is there anything you can recommend to optimise my set up for large datasets and is there anything you could suggest I tweak in iCarousel?
While I'm asking....
I was just curious if anyone has written a transform that once a thumbnail in a carousel is taped which takes that selected item and simulates a zoom out to a larger picture to be inspected and then dismissed by a tap? The tap part I can do.
I assume that I could create a alpha 0 view over the top of the current selected thumbnail and then animated the transform to create a zoom effect while progressing the alpha from 0 to 1 or maybe .9ish. Then just reverse it when you tap on it to cause it to shrink back into the thumbnail shown in the carousel.
Just wanted to ask before I commit a few days to mess with it!
Thanks in advance.
Hi!
I use icarousel to load some info on the view... If I try to change the source of my info how can I delete all carousel views on the screen and load each others?
thanks
I integrated iCarousel into my project and of course implement the necessary methods in iCarouselDelegate and iCarouselDataSource but the transformed components inside the carousel do not have smooth edges. I followed the example code closely but couldn't find the reason for it. Is there any property I should change so that it will show correctly?
Got a problem with having an amount greater than 22 record. The animation is lost with that amount, or someone has already solved this problem??
Thanks for this awesome control! Do you think it is possible to implement something like "pull to refresh" with this? If so, how would you do it?
Thanks,
Shukuyen.
hello,
error caused when tapped, I got (ex_bad_access)
at
and when I use button i got error in ibaction for that button in the same function
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.