Ios UICollectionView单元格在秒后或录制屏幕时消失

Ios UICollectionView单元格在秒后或录制屏幕时消失,ios,objective-c,uicollectionview,uicollectionviewcell,Ios,Objective C,Uicollectionview,Uicollectionviewcell,我正在用iOS 7.0上的Xcode 5.1开发我的第一个iPad应用程序,我正在使用UICollectionView 单击导航栏中的第一个选项卡时,我的CollectionViewController包含在初始控制器的视图中 几秒钟后或者当我点击屏幕上的某个地方时,细胞就会消失 如果我把CollectionViewController作为初始视图控制器,单元格就可以了 我不明白! 我需要帮助 #import "ActiviteViewController.h" #import "AppDel

我正在用iOS 7.0上的Xcode 5.1开发我的第一个iPad应用程序,我正在使用
UICollectionView

单击导航栏中的第一个选项卡时,我的CollectionViewController包含在初始控制器的视图中

几秒钟后或者当我点击屏幕上的某个地方时,细胞就会消失

如果我把CollectionViewController作为初始视图控制器,单元格就可以了

我不明白! 我需要帮助

#import "ActiviteViewController.h"
#import "AppDelegate.h"
#import "Embarcation.h"
#import "CollectionActiviteCellController.h"

@interface ActiviteViewController ()

@end

@implementation ActiviteViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self; }

- (void) viewWillAppear: (BOOL) animated {
    [super viewWillAppear:animated];
    [[self view] setFrame: CGRectMake(0, 0, 1024, 618)]; }


-(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
    return YES; }

- (void)viewDidLoad {
    [super viewDidLoad];
    AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;

    // Fetching Records and saving it in "fetchedRecordsArray" object
    self.embarcationsArray = [appDelegate getAllPayments];
    [self.collectionView reloadData]; }

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

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    // Return the number of sections.
    return 1; }

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [self.embarcationsArray count]; }

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
     CollectionActiviteCellController *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MonEmbarcation"
forIndexPath:indexPath];

    Embarcation * embarcation = [self.embarcationsArray objectAtIndex:indexPath.row];
    myCell.labelEmbarcation.text = [NSString stringWithFormat:@"%@, %@ ",embarcation.nom,embarcation.etat];

    NSLog([NSString stringWithFormat:@"%@, %@ ",embarcation.nom,embarcation.etat]);

    return myCell; }

/*
#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. }
*/

@end

通过代码或情节提要将数据源出口连接到视图控制器

代码:

或者通过脚本ctrl+从集合视图拖动到表示视图控制器对象的黄色矩形,然后选择“数据源”


您是否正确设置了数据源?当用来填充collectionCells的数组为空时,您可能正在某处重新加载数据。您是否已注册CustomCell?不管怎样。发布与收集视图相关的所有代码我发布所有回复代码,我尝试删除重新加载的数据,但没有任何更改无需删除重新加载的数据:O!您只需要检查“embarcationsArray”中的状态和数据。能否替换“[appDelegate getAllPayments];”用硬编码数组作为实验?此外,我没有看到您注册您的手机(或提及任何类型的手机),因此您可以将这一行添加到viewDidLoad方法中吗?[self.collectionView注册表类:[CollectionActiviteCellController类]forCellWithReuseIdentifier:@“CollectionActiviteCellController”];。顺便说一句,我假设您正确设置了“CollectionActiviteCellController”以扩展“UICollectionViewCell”!同样有趣的是:。
self.collectionView.delegate = self;