基本上我一直在寫iOS應用程序大約3天(在閱讀書籍以獲得設計模式和框架等基本知識之後),並花費了整整1天這個。我無法顯示我的CollectionView
。我有一個以TabBarView
開頭的故事板,兩個選項卡(一個是TableView
,另一個是UIView
),但第三個選項卡(UICollectionView
)即使在設置後也會顯示黑屏。 我如何設置它:在Xcode中遇到與CollectionView有關的問題 - 顯示器的黑屏
1)拖着一個視圖控制器到故事板
2)使我UITabBarController
之間的關係segue
新ViewController
3)拖着UICollectionView
新ViewController
4)拖動4 UICollectionViewCell's
到CollectionView
5)dragg ED 4 UILabels
成說CollectionViewCell's
6)取得了新的CollectionView's
委託&數據源和我CollectionView
類的頭文件之間的連接(這可能是我哪裏錯了,我沒有讓我的ViewController.h
類的連接因爲我用這一個我UITableView
,並認爲一個新的類是必要的)
7)宣佈我CollectionView.m
文件中的下列方法
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//Populates each cell using the data given (no data in this case).
//Should return a CollectionViewCell.
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
return cell;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
//Gets the number of cells in each section.
//Should return an integer value.
return 2;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
//Tells the collection view the number of sections it should have.
//Should return an integer value.
return 4;
}
我感覺有這麼我錯過了,因爲這個邏輯對我來說是一個程序員,但是,在Xcode中有這麼一點經驗,也許我忘了把這個類連接到我的CollectionView
什麼的。有人知道我出錯了嗎?如果你想知道,我使用這個CollectionView更多的導航技術,而不是顯示美妙的圖像或任何東西,我將在稍後他們實際顯示在模擬器中時用通用圖像填充它們。 謝謝