私はコレクションビューを使ってRSSリーダーアプリケーションを開発しました。私の問題は、最初の起動時に、アプリが空白になるということです。コレクションビューを自動的に再読み込みするにはどうすればよいですか?
このプロセスは、RSSフィードをWebから取得し、デバイス上の一時ファイルに保存し、コレクションビューで表示することです。
私の質問はどうやってファイルを読み込んだら、自動的にデータを読み込むようにするのですか?ユーザーに最初の空白の画面が表示されないようにします。
私はそれが最初のビューでは動作しません。しかし、このコード
[self.collection1 performBatchUpdates:^{
[self.collection1 reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
を追加しようとしています。
私はappdelegateから何かする必要がありますか?またはコレクションビューコントローラ自体から取得できますか?
以下
を教えてください自分のデータを取得し、表示するために使用するコードです....
#pragma mark - UICollectionViewDataSourceDelegate
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [_articleListmain count];
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MainCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"articleCellmain"
forIndexPath:indexPath];
NSDictionary *item = [_articleListmain objectAtIndex:indexPath.item];
// set the article image
[cell.image setImageWithURL:[item objectForKey:@"image"]];
// set the text of title UILabel
cell.title.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"title"]];
cell.title.textColor = [UIColor colorWithRed:33.0f/255.0f green:74.0f/255.0f blue:146.0f/255.0f alpha:1.0f];
// set the text of summary UILabel
cell.description.text = [NSString stringWithFormat:@"%@\n\n\n\n\n\n\n\n\n", [item objectForKey:@"description"]];
cell.targetURL.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"link"]];
cell.category.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"category"]];
cell.date.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"pubDate"]];
cell.image.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"placement.png"]];
return cell;
}
私はコレクションビューのコントローラーで、またはデータの解析が完了した後に使用します。それは私が持っている問題です。 –
私のコレクションビューでログに表示され、再ロードされても表示されないことが表示され、空白の表示が変わることを確認しました –
コードを見ることなく、実際にはリロード。 cellForItemAtIndexPathに、データソースがあるかどうかを調べて、データがそこにあることを確認しましたか?おそらく、そのメソッドのコードを含むようにあなたの投稿を修正したいと思うでしょう。 – RegularExpression