Open robipresotto opened 10 years ago
A UIView can only have one superview. If you try to add a UIView that is already inside an iCarousel item to another item it will automatically be removed from the first one, leaving it blank (this is a feature of UIKit, not iCarousel).
If you want to have the same item on screen twice, you will have to create two separate copies of the view, you can't reuse the same view multiple times.
Can you explain me better?
'm getting this error: UICatalog: Invalid asset name supplied:, or invalid scale factor: 2.000000
UICatalog isn't a property of iCarousel, so I don't think that has anything to do with it.
My point about views is that if you have two copies of self.tableViewMovie in the carousel, only one of them will be displayed because tableViewMovie is a view and you can only have one copy of the same view on screen at once.
You need to create a unique instance of tableViewMovie for each carousel item, you can't store one copy in a property and reuse it.
Thank you nick,
I forgot to allocate memory for a new tableview, now working better… sometimes the screen goes blank…
new code,
(UIView )carousel:(iCarousel )carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {
if (carousel == self.carouselMovies) {
view = [[UIView alloc] initWithFrame:self.carouselMovies.bounds];
[view setBackgroundColor:[UIColor blackColor]];
if ([self.collectionArray count] > 0) {
if ([[[self.collectionArray objectAtIndex:index] valueForKey:@"type"] isEqualToString:@"geolocation"]) {
AppDelegate *appDelegate = [AppDelegate sharedManager];
appDelegate.styleTypeShared = 0;
// CREATE TABLEVIEW GEO
self.tableViewGeo = [[UITableView alloc] initWithFrame:self.carouselMovies.bounds style:UITableViewStyleGrouped];
[self.tableViewGeo setDelegate:self];
[self.tableViewGeo setDataSource:self];
self.tableViewGeo.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[self.tableViewGeo setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[self.tableViewGeo setSeparatorColor:[UIColor blackColor]];
[self.tableViewGeo setBackgroundColor:[UIColor colorWithRed:33.0f/255.0f green:37.0f/255.0f blue:40.0f/255.0f alpha:1.0f]];
self.tableViewGeo.showsVerticalScrollIndicator = NO;
[self.tableViewGeo setSeparatorInset:UIEdgeInsetsZero];
self.refreshControlGeo = [[UIRefreshControl alloc] init];
[self.refreshControlGeo addTarget:self action:@selector(refreshTableViewGeo:) forControlEvents:UIControlEventValueChanged];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"Pull to Refresh"];
NSRange fullRange = NSMakeRange(0, [string length]);
[string addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:fullRange];
[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Avenir-Book" size:12] range:fullRange];
[self.refreshControlGeo setAttributedTitle:string];
[self.refreshControlGeo setTintColor:[UIColor cyanColor]];
[self.tableViewGeo addSubview:self.refreshControlGeo];
[view addSubview:self.tableViewGeo];
cityNameLocation = [[self.collectionArray objectAtIndex:index] valueForKey:@"title"];
self.resultsArray = [[self.collectionArray objectAtIndex:index] valueForKey:@"result"];
}
if ([[[self.collectionArray objectAtIndex:index] valueForKey:@"type"] isEqualToString:@"theater"]) {
AppDelegate *appDelegate = [AppDelegate sharedManager];
appDelegate.styleTypeShared = 1;
// CREATE TABLEVIEW THEATER
self.tableViewTheater = [[UITableView alloc] initWithFrame:self.carouselMovies.bounds style:UITableViewStyleGrouped];
[self.tableViewTheater setDelegate:self];
[self.tableViewTheater setDataSource:self];
self.tableViewTheater.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[self.tableViewTheater setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[self.tableViewTheater setSeparatorColor:[UIColor blackColor]];
[self.tableViewTheater setBackgroundColor:[UIColor colorWithRed:33.0f/255.0f green:37.0f/255.0f blue:40.0f/255.0f alpha:1.0f]];
self.tableViewTheater.showsVerticalScrollIndicator = NO;
[self.tableViewTheater setSeparatorInset:UIEdgeInsetsZero];
[view addSubview:self.tableViewTheater];
self.resultTheaterArray = [[self.collectionArray objectAtIndex:index] valueForKey:@"result"];
[self.tableViewTheater reloadData];
}
if ([[[self.collectionArray objectAtIndex:index] valueForKey:@"type"] isEqualToString:@"movie"]) {
AppDelegate *appDelegate = [AppDelegate sharedManager];
appDelegate.styleTypeShared = 2;
// CREATE TABLEVIEW MOVIE
self.tableViewMovie = [[UITableView alloc] initWithFrame:self.carouselMovies.bounds style:UITableViewStyleGrouped];
[self.tableViewMovie setDelegate:self];
[self.tableViewMovie setDataSource:self];
self.tableViewMovie.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[self.tableViewMovie setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[self.tableViewMovie setSeparatorColor:[UIColor blackColor]];
[self.tableViewMovie setBackgroundColor:[UIColor colorWithRed:33.0f/255.0f green:37.0f/255.0f blue:40.0f/255.0f alpha:1.0f]];
self.tableViewMovie.showsVerticalScrollIndicator = NO;
[self.tableViewMovie setSeparatorInset:UIEdgeInsetsZero];
[view addSubview:self.tableViewMovie];
self.resultMovieArray = [[self.collectionArray objectAtIndex:index] valueForKey:@"result"];
[self.tableViewMovie reloadData];
}
}
}
return view;
}
and the tableview reloadData on the currentItemIndexDidChange… it's right?
Hi, nick : )
I'm losing the contents of the screen when I have two items of the same type side by side on the carousel… Why? Look the screen shots...
My code,
iPhone Simulator (two itens the same type, side by side...
Great job man : )) Best Regards,