Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将多维数组中的图像加载到UIImageView_Iphone_Objective C_Ios_Xcode_Uiimageview - Fatal编程技术网

Iphone 将多维数组中的图像加载到UIImageView

Iphone 将多维数组中的图像加载到UIImageView,iphone,objective-c,ios,xcode,uiimageview,Iphone,Objective C,Ios,Xcode,Uiimageview,我正在将一个图像加载到一个自定义单元格中,并在整个代码中从XML构建一个数组,我希望在nib文件中将其设置为UIImageView 我的数组被构建为totalArray,然后我在CellForRowatineXpatht中执行以下操作: newObj1=[totalArray objectAtIndex:indexPath.row]; aCell.lblRouteText.text = newObj1.routeText; 以及以下内容以加载我的图像作品(静态): 但是,当我尝试使用以下方法放

我正在将一个图像加载到一个自定义单元格中,并在整个代码中从XML构建一个数组,我希望在nib文件中将其设置为UIImageView

我的数组被构建为totalArray,然后我在CellForRowatineXpatht中执行以下操作:

newObj1=[totalArray objectAtIndex:indexPath.row];
aCell.lblRouteText.text = newObj1.routeText;
以及以下内容以加载我的图像作品(静态):

但是,当我尝试使用以下方法放入阵列时:

UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[newObj1.routeImage]]];
我得到一个预期的标识符错误

有什么建议吗


Tom

您正在编写
[newObj1.routeImage]
您只需要
newObj1.routeImage
,即您的最后一行可能应该是:

UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:newObj1.routeImage]];
当您使用方括号(而不是在C数组的上下文中)时,您应该始终具有某种形式的
[xy]
,这意味着“将消息
y
发送给接收者
x

关于线程的注意事项:使用
[NSData dataWithContentsOfURL::
时要小心,因为它会在获取URL内容时阻塞。如果在主线程上调用此函数,则会阻止用户界面,应用程序将无响应


(顺便说一句,如果您发布错误消息,最好尽可能从控制台复制并粘贴完整的实际错误行,这将最大限度地提高我们理解问题的机会。)

D'oh,太简单了。谢谢你
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:newObj1.routeImage]];