跟实例基本差不多,但每次都显示image对象为nil,请问大神哪里有问题?
//
// ViewController.m
// PhotoViewer
//
// Created by yonzhang on 13-10-13.
// Copyright (c) 2013年 yonzhang. All rights reserved.
//
#import "ViewController.h"
#import "ImageCell.h"
@interface ViewController ()
@property NSMutableArray *photoArray;
@end
@implementation ViewController
(void)viewDidLoad
{
[super viewDidLoad];
// self.collectionView
self.collectionview.delegate = self;
self.collectionview.dataSource = self;
[self.collectionview registerClass: [ImageCell class] forCellWithReuseIdentifier:@"Cell"];
// self.collectionview.dataSource = self;
// Do any additional setup after loading the view, typically from a nib.
}(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma Collection View Data Souce
(NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 1;
}
-(UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
// UIImage *testImage = [UIImage imageNamed:@"4.JPG"];
cell.image.image = [UIImage imageNamed:@"4.JPG"];
return cell;
}
#pragma custommethod
@end