KSCollectionViewController
视图控制器:storyboard中 的 ViewController 必须关联相关的类 :第三个custom class
视图的cell: storyboard中 的 CollectionViewCell 必须关联相关的类 :第三个custom class KSCollectionViewCell, 第四个 collection reusable view 的identifier选项填写 KSCollectionViewCell
跳转过来时一定要采用storyboard的跳转方式进来
打开storyboard 选中ViewController 点击第四个show the Attributes inspector 在ViewController 中 勾选 Is Initial View Controller否则跳转时候会找不到这个ViewController从而为nil 报错 (不能初始化)
第一种:
@interface KSCollectionViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView; //storyboard中拉的CollectionView
self.myCollectionView.delegate = self;
self.myCollectionView.dataSource = self;
第二种:
storyboard中拉的CollectionView 往viewController上拉线 delegate 和datasouce
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView; //storyboard中拉的CollectionView
最后
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
方法中:
KSCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KSCollectionViewCell" forIndexPath:indexPath];
注意:选对地方 [self.myCollectionView reloadData];
self.myCollectionView.delegate = self;
self.myCollectionView.dataSource = self;
字典
{
"agent_name" = "\U7c73\U5176\U6797";
"car_type_name" = "\U5965\U8feaA4";
id = 1;
"intro_pic" = "savefile/commodity/2016-02-20/ad5e4909dcc04f17916c4c0f63c559e4.jpg";
"new_music" = "
"old_music" = "
price = 100;
"product_des" = "\U6b64\U6b21X5\U7684\U6539\U6b3e\U66f4\U91cd\U8981\U7684\U4e00\U70b9\U5c31\U662f\U589e\U5f3a\U5e74\U8f7b\U6c14\U606f\Uff0c\U5c3e\U90e8\U867d\U7136\U4fdd\U7559\U4e86\U4e0a\U4e00\U4ee3\U7a33\U91cd\U7684\U6c14\U606f\Uff0c\U4f46\U6574\U4f53\U7684\U7ec6\U8282\U6539\U53d8\U8ba9\U5176\U770b\U8d77\U6765\U66f4\U65f6\U5c1a\Uff0c\U66f4\U52a0\U8fd0\U52a8\Uff0c\U66f4\U5bb9\U6613\U88ab\U5e74\U8f7b\U7fa4\U4f53\U63a5\U53d7\U3002\U5176\U4e2d\U5c3e\U706f\U4f9d\U7136\U662f\U706f\U5e26\U5f0f\U8bbe\U8ba1\Uff0c\U5176\U4e2d\U8be0\U91ca\U7684\U610f\U4e49\U662f\U70e7\U7ea2\U7684\U6392\U6c14\U7ba1\Uff0c\U4ee3\U8868\U5b9d\U9a6c\U8fd0\U52a8\U7684\U7cbe\U9ad3\U3002";
"product_images" = "savefile/commodity/2016-02-20/ad5e4909dcc04f17916c4c0f63c559e4.jpg";
"product_name" = "x5\U6fc0\U5149";
}
字典是{=;=;=;=;=}
数组 是{,,,,,,}