ios - 比数据参数更多的 '%' 转换

标签 ios image uicollectionview parse-platform

在 DetailView 中,我试图显示来自 Parse.com 后端的多于 1 张图像,因此我有以下代码:

编辑:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

static NSString *cellIdentifier = @"Cell";
VestimentaDetailCell *cell = (VestimentaDetailCell *) [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

static int index = 1;
PFFile *imageFile = [self.vestimenta objectForKey:[NSString stringWithFormat:@"image_%d", index ]];

[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {

cell.imageFile.image = [UIImage imageWithData:data];


}
}];

return cell;
}

有效.. 问题是一旦用户查看了图像,它们就不再出现了。

所以我尝试只实现:

PFFile *imageFile = [self.vestimenta objectForKey:[NSString stringWithFormat:@"image_%d"]];

但随后我收到“'%' 转换多于数据参数”的错误。 如何设置密码?

最佳答案

改变

PFFile *imageFile = [self.vestimenta objectForKey:[NSString stringWithFormat:@"image_%d"]];

PFFile *imageFile = [self.vestimenta objectForKey:[NSString stringWithFormat:@"image_%@", index ]];

当你写类似NSLog(@"%d %f %@")的东西时,你应该像这样传递参数:

NSLog(@"%d %f %@", someInt, someFloat, someString);

你可以试试这个:

PFFile *imageFile = [self.vestimenta objectForKey:[NSString stringWithFormat:@"image_%d+1", indexPath.row ]];

希望对您有所帮助。

关于ios - 比数据参数更多的 '%' 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23158289/

相关文章:

ios - 苹果会允许这种非公开方法吗?

ios - NavigationItem 中的 titleView 不考虑 iOS 11 中的框架高度

ios - 在数组的每个项目中显示不同的价格

android - 麦克风输入属性

html - 背景 : url and filter:brightness

java - 如何解压png文件

ios - 在 iOS 7 上创建类似 Evernote 的弹性 UICollectionView

ios - SetDelegate 导致 'unrecognized selector' 异常

ios - UICollectionView:ScrollToItem 到中心单元格在水平 Collection View 上不起作用

java - 如何将图像添加到 CSV 文件?