UICollectionView

1. How to be compatible with iOS 5 due to for iOS6?

Answer: Using UITableView instead of it. PSCollectionView or PSTCollectionView.

2. Reused Identifier: /

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

Answer: [self.collectionView registerClass:[CVContactPickerImageCollectionCell class] forCellWithReuseIdentifier:@”selectingCollectionViewCell”];

3. Image did not show up for each cell. And it has function cellForItemAtIndexPath already.

– (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

CVContactPickerImageCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@”selectingCollectionViewCell” forIndexPath:indexPath];

if (!cell)

cell = [[CVContactPickerImageCollectionCell alloc] init];

[[cell collectionImageView]setImage:[UIImage imageNamed:[_arrayCollectionImages objectAtIndex:indexPath.item]]];

//    cell.label.text = [NSString stringWithFormat:@”%d”,indexPath.item];

return cell;

}

Answer: No set up initialization in cell.m file.

        self.collectionImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];

self.collectionImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

[self.contentView addSubview:self.collectionImageView];

4. UIImage namedWith:@”defaultImage.png” How to change the image from the server?

– (void) viewDidLoad{

//    _arrayCollectionImages = [[NSMutableArray alloc] initWithObjects:@”defaultPerson.png”, @”defaultPerson.png”,nil];

_arrayCollectionImages = [[NSMutableArray alloc] init];

for (NSString* selectedKey in _model.selectedKeys) {

User* userInfo = [User userWithUniqueUserId:selectedKey inManagedObjectContext:[[DataStore sharedDataStore] managedObjectContext]];

[_arrayCollectionImages addObject:[userInfo iconUrlOfSize:@”medium”]];

}

}

– (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

CVContactPickerImageCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@”selectingCollectionViewCell” forIndexPath:indexPath];

if (!cell)

cell = [[CVContactPickerImageCollectionCell alloc] init];

//    UIImage* image = [_arrayCollectionIconView objectAtIndex:indexPath.item] ;

//    [[cell collectionImageView]setImage:[UIImage alloc]];

UIImage* image = [[TTURLCache sharedCache] imageForURL:[_arrayCollectionImages objectAtIndex:indexPath.item]];

[[cell collectionImageView]setImage:image];

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s