ios - 如何为每个数组保存图像

标签 ios xcode arrays uitableview uiimageview

我正在尝试为 UITabelView 中的每个数组设置图像。如何为照片库中的每个阵列设置图像?这样我就可以在 UITableView 的单元格中查看它。

我希望这有帮助,这是我的简单代码 Download

从现在开始谢谢。

最佳答案

你可以这样做:

NSArray *photos = [[NSArray arrayWithObjects:   
                        [UIImage imageNamed:@"1.png"],
                        [UIImage imageNamed:@"2.png"],
                        [UIImage imageNamed:@"3.png"],
                        [UIImage imageNamed:@"4.png"],
                        nil] retain]; // Arrange images in the same order your table data is arranged.

现在,在 cellForRowAtIndexPath: 方法中:

cell.imageView.image = [photos objectAtIndex:indexPath.row];

关于ios - 如何为每个数组保存图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11792048/

相关文章:

iphone - 具有自定义上下文菜单选项的 iOS 浏览器应用程序

ios - Xcode 不会越过崩溃

ios - 创建一个类来获取所有按钮委托(delegate)

iPhone,如何设置 View 背景,如设置屏幕灰色样式?

c++ - 为什么不能使用外部常量定义数组?

c - c中数组中的随机字符串

ios - 如何保存处理程序中生成的数据?

ios - 如何检测模拟器中运行的iPad pro?

arrays - Bash 将数组传递给函数插入空元素

使用 AFNetworking 没有证书的 iOS SSL Pinning?