我是编程的新手,我正在尝试为我的iOS开发类创建一个照片应用程序,根据特定的标签显示用户照片,但我没有运气。我有Instagram的API以及我的client_id。当我运行它时,没有任何错误,但屏幕只是黑色。我需要还有什么才能让图像显示出来?这就是我到目前为止所拥有的。提前谢谢!
@interface ViewController () <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property NSMutableArray *picFeed;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"https://api.instagram.com/v1/tags/chicago/media/recent?count=100&client_id=d3eed38ae896497e9e58298dd793333b"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError) {
self.picFeed = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&connectionError];
[self.collectionView reloadData];
}];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.picFeed.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CellID" forIndexPath:indexPath];
return cell;
}