Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because you use storyboard, MyCollectionViewCell will always load from stroyboard.</p> <p>So, change MyCollectionViewCell interface:</p> <pre><code>@interface MyCollectionViewCell : UICollectionViewCell @property (weak, nonatomic) IBOutlet UIImageView *tweetImageView; @end </code></pre> <p>And link the property in stroryboard.</p> <hr> <p>Well, I write that for you.</p> <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCollectionViewCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath]; if (!myCell) { myCell = [[MyCollectionViewCell alloc] initWithFrame:CGRectMake(0,0,myCell.frame.size.width , myCell.frame.size.height)]; } [myCell.tweetImageView setImage:[[xmlParser tweets] objectAtIndex:indexPath.row]]; return myCell; } </code></pre> <p>And MyCollectionViewCell interface and implementation:</p> <pre><code>@interface MyCollectionViewCell : UICollectionViewCell @property (weak, nonatomic) UIImageView *tweetImageView; @end @implementation MyCollectionViewCell - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { UIImageView *aImageView = [[UIImageView alloc] initWithFrame:self.bounds]; aImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [self addSubview:aImageView]; self.tweetImageView = aImageView; } return self; } @end </code></pre> <hr> <p>You set currentTweet to <code>[[xmlParser tweets] objectAtIndex:indexPath.row]</code>?</p> <p>I think it's nil. Check it.</p> <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCollectionViewCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath]; UIImage *currentTweet = [[xmlParser tweets] objectAtIndex:indexPath.row]; UIImageView *tweetImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,myCell.frame.size.width , myCell.frame.size.height)]; tweetImageView.image = currentTweet; NSLog(@"%@", tweetImageView.image); // Check tweetImageView.image whether nil or not. [myCell setBackgroundView:tweetImageView]; return myCell; } </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. VO
      singulars
      1. This table or related slice is empty.
    2. 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