2014-10-14 2 views
0

Я пытаюсь использовать UICollectionViewController на Xcode 6, но я не вижу пользовательские элементы ячейки или прототипа. Я помещал Label в ячейку белого цвета, я реализовал numberOfSections и numberOfItemsInSection, но проблема не устранена. Может мне помочь? Заранее спасибо.Не показывать UICollectionViewController

@implementation CollectionViewController 

static NSString * const reuseIdentifier = @"Cell"; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Uncomment the following line to preserve selection between presentations 
    // self.clearsSelectionOnViewWillAppear = NO; 

    // Register cell classes 
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 

    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 
*/ 

#pragma mark <UICollectionViewDataSource> 

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 
#warning Incomplete method implementation -- Return the number of sections 
    return 1; 
} 


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 
#warning Incomplete method implementation -- Return the number of items in the section 
    return 5; 
} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 

    // Configure the cell 

    return cell; 
} 

ответ

0

Привет попытаться установить некоторые данные по адресу: cellForItemAtIndexPath

Небольшой пример моего кода

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    MEMediaView *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MEMediaView" forIndexPath:indexPath]; 
    [cell awakeFromNib]; 
    [cell setMemryMediaData:[mediaArray_ objectAtIndex:indexPath.row]]; 
    [cell setMediaContent]; 
    if (shadow) 
    { 
     [cell shadeCoverImage]; 
    } 

    return cell; 
} 

Также не забудьте установить делегатов:

self.collectionView.delegate = self; 
self.collectionView.dataSource = self; 
+0

I Использование раскадровки –

+0

Я отредактировал мой ответ, пожалуйста, попробуйте –

+0

У меня есть это на подключении ector, я не знаю, почему это проблема, UITableViewController это нормально, но UICollectionViewController я показываю черный экран, я меняю цвет фона с ячейкой прототипа, но проблема сохраняется. –

Смежные вопросы