Database Reference
In-Depth Information
-(void)configureCellForEntry:(NSString *)entry withDelegate:(id<EntryCollectionViewCellDelegate>)
delegate {
if(entry == nil)
return;
_entry = entry;
_delegate = delegate;
_imgPhoto.image = [UIImage imageNamed:@"ImgCellNoImage"];
_lblDisplayName.text = _entry;
}
The final class method that we want to override is prepareForReuse . This method is called right
before a view is reused. Since we don't want any of the cell's previous data to display we use this
method to reset the image view and the label. We also set our entry back to nil.
-(void)prepareForReuse {
_entry = nil;
_imgPhoto.image = nil;
_lblDisplayName.text = @"";
}
Now is a good time to move back to the storyboard and connect everything for this cell. Follow
these steps:
1.
Select Main.Storyboard .
2.
Select the CollectionViewCell inside the UICollectionViewController .
3.
Under the Identity Inspector, change Class to EntryCollectionViewCell .
4.
Under Attribute Inspector, set the Identifier to EntryCollectionViewCell .
5.
Select the Connection Inspector.
6.
Under outlets, click and drag from the little circle to the right of imgPhoto to
the UIImageView in the cell.
7.
Do the same thing for lblDisplayName and drag it to the label.
FriendsCollectionViewController
Open up the FriendsCollectionViewController.h file and add the import statement for
EntryCollectionViewCell.h .
#import "EntryCollectionViewCell.h"
 
Search WWH ::




Custom Search