StoryBoard를 사용하여 UITableViewCell 내부에 collectionView를 빠르게 빌드하는 방법 (How to use StoryBoard quick build a collectionView inside UITableViewCell)


문제 설명

StoryBoard를 사용하여 UITableViewCell 내부에 collectionView를 빠르게 빌드하는 방법 (How to use StoryBoard quick build a collectionView inside UITableViewCell)

아래 그림과 같이 tableView 셀 안에 collectionView를 빌드합니다. 다음 IBOutlet 드래그 사용자 정의 UITableViewCell에서 ServicePromotionItemCell 설정 UICollectionViewDataSource.

메인 코드:

#import "ServicePromotionCollectionView.h"
#import <HexColor.h>
@interface ServicePromotionItemCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (strong, nonatomic) IBOutlet ServicePromotionCollectionView *promotionCollectionView;
@end

@implementation ServicePromotionItemCell

‑ (void)awakeFromNib {
    UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];

    _promotionCollectionView = [[ServicePromotionCollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout];
    _promotionCollectionView.delegate = self;
    _promotionCollectionView.dataSource = self;
    [_promotionCollectionView registerClass:ServicePromotionCollectionViewCell.self forCellWithReuseIdentifier:@"ServicePromotionCollectionCell"];
}

#pragma mark ‑ UICollectionViewDataSource
‑ (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 3;
}

‑ (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ServicePromotionCollectionCell" forIndexPath:indexPath];

    return cell;
}
}

하지만 앱을 실행할 때 초기화되지 않는 것 같습니다. UICollectionView, 내가 놓친 것이 있습니까? 도와주세요. 감사합니다 :)

jamesuser5638723)

참조 문서

  1. How to use StoryBoard quick build a collectionView inside UITableViewCell (CC BY‑SA 2.5/3.0/4.0)

#ios7 #objective-c






관련 질문

iOS 7 Safari 사용자 에이전트를 결정하는 가장 좋은 방법은 무엇입니까? (What is the best way to determine iOS 7 Safari user agent?)

iOS 7, 탐색바가 반투명하지 않습니다... 더보기 탭이 반투명하게 보이는 이유는 무엇입니까? (iOS 7, navigation bar has no translucency... why does More tab look translucent?)

사진 촬영 후 사진 사용 또는 재촬영을 선택할 수 없습니다. (After Taking Picture cannot select Use Photo or Retake)

구문 분석 문제: 'stringByAppendingFormat' 모듈을 찾을 수 없습니다. (Parse Issue: Module 'stringByAppendingFormat' not found)

탐색 컨트롤러로 보기로 돌아가기 위해 자동 제스처를 끄는 방법은 무엇입니까? (How to turn off the automatic gesture to go back a view with a navigation controller?)

IOS 7 + 강제 컨트롤러의 경우 세로 방향 (IOS 7 + For force controller Orientation to Portrait)

Phonegap 앱은 iOS7에서 실행되지 않습니다. (Phonegap App doesn't run on iOS7)

UITableViewCellStyle2 색조 색상 설정 (Setting UITableViewCellStyle2 Tint Color)

iOS - flexbox 내부에 입력 요소가 있는 부동 커서 (iOS - Floating cursor with input elements inside flexbox)

UITableView는 iOS 7에서 작동하지만 iOS 8에서는 깨져 보입니다. (UITableView works in iOS 7 but appears crushed in iOS 8)

핵심 데이터 튜토리얼 (Core data tutorial)

StoryBoard를 사용하여 UITableViewCell 내부에 collectionView를 빠르게 빌드하는 방법 (How to use StoryBoard quick build a collectionView inside UITableViewCell)







코멘트