2015-11-02 60 views
1

我從一個URL數據和我編碼我的密碼&做shaa256我又通過密碼來獲取數據,形成了自己的網址無法在集合視圖中加載數據?

網址:http://exampleurl/users

,我可以能夠打印出我的JSON響應在我的控制檯.its工作正常。現在我想顯示我的數據在我的收藏視圖(如網格形式)。我做了所有的故事板工作,我做了所有的委託方法。

我的問題:

  1. 得到錯誤'UICollectionView dataSource is not set'
  2. 我的數據不會在集合視圖加載。

請幫我提前感謝!

回答

1

refresh Data

for(int i=0;i<[arrayFiles count];i++) 
{ 
    NSString *strCreatedTime = [NSString stringWithFormat:@"%@",[[arrayFiles objectAtIndex:i] valueForKey:@"created_time"]]; 
    NSString *strLastModifiedTime = [NSString stringWithFormat:@"%@",[[arrayFiles objectAtIndex:i] valueForKey:@"last_modified_time"]]; 
    NSString *strID = [NSString stringWithFormat:@"%@",[[arrayFiles objectAtIndex:i] valueForKey:@"id"]]; 
    NSString *strName = [NSString stringWithFormat:@"%@",[[arrayFiles objectAtIndex:i] valueForKey:@"name"]]; 


    [arrayPDFName addObject:strName]; 
} 

之後呼籲重新加載/刷新這一行/更新數據

dispatch_async(dispatch_get_main_queue(),^{ 
[self.mycollectionView reloadData]; 
}); 

你的第一個錯誤

- (void)viewDidLoad { 
[super viewDidLoad]; 


self.mycollectionView.dataSource = self; 
self.mycollectionView.delegate = self; 

[self getdata]; 

} 

檢查你的.h文件,確定要刪除確保你的對象符合數據源代理協議。例如。

@interface ViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource> 
+0

老兄你只亞爾..... OK會看出來這個 – 2131

+0

是它只有一個section.Having 2個問題的工作:1。我有3個部分,需要告訴集合視圖它們是空的2 。在標題需要每個部分的名稱與他們的文件數量(例如:藍色(3),白色(0)....像我的圖像顯示以上 – 2131

+0

兄弟爲我的上述問題 – 2131

1

看起來像mycollectionViewviewDidLoad沒有設置。只需將出口屬性連接到故事板。