2013-03-15 4 views

답변

0

예.

@interface MyViewController:UIViewController<UICollectionViewDelegate, UICollectionViewDataSource> 
@end 

는 다음 하는 .m 파일에 당신이 필요한 UICollectionViewDataSourceUICollectionViewDelegate 방법을 구현 : 프로그래밍 방식

-(void)loadView 
{ 
[super loadView]; 

UICollectionViewFlowLayout *layout= [[UICollectionViewFlowLayout alloc]init]; 
self.collectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout]; 
self.collectionView.delegate=self; 
self.collectionView.dataSource=self; 
[self.collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin]; 

[self.collectionView setBackgroundColor:[UIColor clearColor]]; 
[self.collectionView registerClass:[UICollectionViewCell class] 
    forCellWithReuseIdentifier:@"Cell"]; 


[self.view addSubView:self.collectionView]; 
} 
0

당신은 다음과 같이 UICollectionViewDataSource 및 UICollectionViewDelegate를 구현하는 UIViewController 하위를 만들 필요가 그것을 만들 수 있습니다

및 override - [UIViewController viewDidLoad] 이렇게 :

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    UICollectionView *collectionView = [UICollectionView alloc] initWithFrame:self.view.bounds]; 
    collectionView.delegate = self; 
    collectionView.dataSource = self; 
    [self.view addSubview:collectionView]; 
} 
+0

자세히보기 http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html –

관련 문제