Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot put <code>UICollectionViewCell</code> directly into the <code>UiCollectionView</code> if you are using <code>Xib</code> file. Its possible only in storyboard. Add a <code>UICollectionViewCell</code> into a separate Xib file. Give your class name. Then register either class or xib before the collection view appears</p> <pre><code> [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:CELL_ID]; </code></pre> <p>Typically this is done in <code>viewDidLoad</code>.</p> <p>This is the implementation of a custom <code>UICollectionViewCell</code> with out using <code>Xib</code> </p> <pre><code> @implementation CollectionViewCell @synthesize imageView = _imageView; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; self.layer.shadowColor = [UIColor blackColor].CGColor; self.layer.shadowRadius = 5.0f; self.layer.shadowOffset = CGSizeMake(2.0f, 2.0f); self.layer.shadowOpacity = 0.5f; // Selected background view UIView *backgroundView = [[UIView alloc]initWithFrame:self.bounds]; backgroundView.layer.borderColor = [[UIColor colorWithRed:0.529 green:0.808 blue:0.922 alpha:1]CGColor]; backgroundView.layer.borderWidth = 10.0f; self.selectedBackgroundView = backgroundView; // set content view CGRect frame = CGRectMake(self.bounds.origin.x+5, self.bounds.origin.y+5, self.bounds.size.width-10, self.bounds.size.height-10); UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame]; self.imageView = imageView; [imageView release]; self.imageView.contentMode = UIViewContentModeScaleAspectFill ; self.imageView.clipsToBounds = YES; [self.contentView addSubview:self.imageView]; } return self; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload