2015-11-23 69 views
1

我有一個需要登錄/註冊的社交應用程序。這是通過爲用戶驗證提供自定義窗口的ParseUI庫完成的。UICollectionView繼續顯示黑屏的註冊

當用戶註冊時,我想顯示一個CollectionView,用戶在其中選擇一些首選項(每個都作爲單元格)並繼續到應用程序。

在註冊後視圖控制器我有這樣的:

- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user { 

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    ChooseLeagueCollectionViewController *clvc = [storyboard instantiateViewControllerWithIdentifier:@"ChooseLeagueViewController"]; 
    [self dismissViewControllerAnimated:YES completion:NULL]; 
    [self presentViewController:clvc animated:NO completion:NULL]; 
    } 

我需要的alloc和init,即使它已經出現在我的故事情節進行的FlowLayout對象?

在我的故事板中,我有一個CollectionViewController,其中包含一個單元,該單元通過一個ImageView和一個標籤鏈接到UICollectionViewCell的子類。這個故事板文件具有作爲CollectionViewController的子類的自定義類「ChooseLeagueViewController」,並且也是數據源和委託。

在.h文件中我有:

@interface ChooseLeagueCollectionViewController : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout> 

在.m文件我實現所有的數據源和委託協議要求所需的方法。在cellForItemAtIndexPath我填充單元格(CollectionviewCell的子類),更改標籤文本和文本顏色,圖像,然後將其返回。

另外我不確定爲什麼我要求註冊像下面這樣的單元格,即使我的單元格在故事板中有一個可重用的標識符。

[self.collectionView registerClass:[LeagueCollectionViewCell class]forCellWithReuseIdentifier:@"leagueCell"]; 

無論如何,當我運行應用程序,註冊後,我被帶到一個完全黑色的屏幕,但電池。該應用程序不會崩潰,並且所有'數據源'方法都被正確調用。

我認爲我試圖展示這個視圖的方式有些問題。

任何猜測我如何能改善我的繼續或錯誤是什麼?

在此先感謝

回答

0

簡單的alloc,init將讓你空控制器沒有與之相關聯的視圖。你必須像這樣通過故事板進行初始化,然後你不必提供任何自定義的初始化/分配,

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@「Main」bundle:nil]; ChooseLeagueCollectionViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@「yourViewControllerIdentifier」]; [self presentViewController:vc animated:NO completion:NULL];

通過選擇您的viewController並在storyboard id中的標識Inspector中指定storyboard中的viewController標識符。 :)