在iPhone上读取由php脚本发送的图像
|
EDIT重新制定了问题:
我通过以下方式从使用iphone的服务器加载图像。
NSURL *url = [NSURL urlWithString:@\"http://www.example.de/getImage.php\"];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
UIImage *im = [UIImage imageWithData:data];
imageView.image = im;
php脚本以该行结尾
$image = file_get_contents($direction);
echo $image;
一切都在这里工作。我反映了图像。
现在,我想接收服务器的两个对象,并尝试稍微更改脚本:
echo array(0=>$image , 1=> $intValue);
我尝试读取此数据已有几个小时,但没有得到结果。
为什么这种尝试不起作用?:
NSArray *arr = [[NSArray alloc] initWithContentsOfURL:url];
UIImage *im = [UIImage imageWithData:[arr objectAtIndex:0]];
在调试时,我使用NSLog来获取图像的描述,它为(null)。
没有错别字或编译或语法错误...
EDIT001:
好的,我现在可能有点矫kill过正,但是我认为尝试这种方法是不可能的。
我再次使用json_encode和base64_encode,如下所示:
echo json_encode(array(\'a\'=>base64_encode($image), \'b\'=>$anotherObject));
在iPhone方面,我使用了一些框架再次解码JSON和base64,并且可以正常工作...
谢谢,如果您对此有疑问,请写下来
没有找到相关结果
已邀请:
2 个回复
徐百晴墓斜
蜂佬渺