我从一个 URL 获取数据并对我的密码进行编码并执行 shaa256 然后我再次传递密码以从我的 url 获取数据
而且我可以在我的控制台中打印我的 Json 响应。它工作正常。现在我想在我的 Collection View 中显示我的数据(如网格形式)。我做了所有的 Storyboard工作,我做了所有的委托(delegate)方法.
我的问题:
- 获取错误
'UICollectionView dataSource is not set'
- 我的数据没有加载到 Collection View 中。
帮我提前谢谢!
最佳答案
为您的刷新数据
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 文件,确保声明您的对象符合数据源和委托(delegate)协议(protocol)。例如
@interface ViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource>
关于ios - 无法在 Collection View 中加载数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33482178/