ios - 如何从图库中获取图像以收集查看单元格?
<p><p>您好,我可以从图库中获取图像,但不会显示到 Collection View 中。我已经编写了这样的代码</p>
<pre><code>- (void)viewDidLoad
{
picker=[init];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
forCellWithReuseIdentifier:@"CELL"];
}
- (IBAction)galleryClicked:(id)sender
{
NSLog(@"GalleryClicked");
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
;
;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
inputImage= info;
NSLog(@"inputImage is :%@",inputImage);
;
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 100;
}
- (MyCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = ;
UIImageView *recipeImageView = (UIImageView *);
UILabel *descLabel = (UILabel *);
self.recipeImageView.image = inputImage;
return cell;
}
</code></pre>
<p>请任何人建议我如何做到这一点。非常感谢帮助。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你需要将<code>self.recipeImageView.image = inputImage;</code>改为<code>recipeImageView.image = inputImage;</code>。</p></p>
<p style="font-size: 20px;">关于ios - 如何从图库中获取图像以收集查看单元格?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28984748/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28984748/
</a>
</p>
页:
[1]