嗨,我是iOS的初学者,在我的项目中,我已经以UICollectionView编程方式创建,好吧它正在工作.
但在这里我的问题是当我滚动CollectionView重复数据加载时,如下面的屏幕所示.
我在这做错了什么?
为什么在滚动CollectionView时加载重复数据?
请帮我.
#import "ViewController.h"
@interface ViewController ()
{
UICollectionView *_collectionView;
NSArray * images;
NSArray * description;
UILabel * NameLabel;
UIImageView *image;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
images = [NSArray arrayWithObjects:@"angry_birds_cake.jpg", @"creme_brelee.jpg", @"egg_benedict.jpg", @"full_breakfast.jpg", @"green_tea.jpg", @"ham_and_cheese_panini.jpg", @"ham_and_egg_sandwich.jpg", @"hamburger.jpg", @"instant_noodle_with_egg.jpg", @"japanese_noodle_with_pork.jpg", @"mushroom_risotto.jpg", @"noodle_with_bbq_pork.jpg", @"starbucks_coffee.jpg", @"thai_shrimp_cake.jpg", @"vegetable_curry.jpg", @"white_chocolate_donut.jpg", nil];
description = [NSArray arrayWithObjects:@"angry_birds_cake.jpg", @"creme_brelee.jpg", @"egg_benedict.jpg", @"full_breakfast.jpg", @"green_tea.jpg", @"ham_and_cheese_panini.jpg", @"ham_and_egg_sandwich.jpg", @"hamburger.jpg", @"instant_noodle_with_egg.jpg", @"japanese_noodle_with_pork.jpg", @"mushroom_risotto.jpg", @"noodle_with_bbq_pork.jpg", @"starbucks_coffee.jpg", @"thai_shrimp_cake.jpg", @"vegetable_curry.jpg", @"white_chocolate_donut.jpg", nil];
UICollectionViewFlowLayout …Run Code Online (Sandbox Code Playgroud)