EDIT重写的问题:阅读在PHP脚本发送的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);
我想现在就阅读该数据几个小时,鸵鸟政策得到的结果。 为什么doesn't这个尝试?:工作
NSArray *arr = [[NSArray alloc] initWithContentsOfURL:url];
UIImage *im = [UIImage imageWithData:[arr objectAtIndex:0]];
在调试时,我用的NSLog来获得图像的描述,它是(空)。
没有错字或编译或语法错误......
EDIT001: 好,我知道了,现在也许有点矫枉过正,但我试过的方式是不可能在我看来。 我再次使用json_encode和BASE64_ENCODE这样的:
echo json_encode(array('a'=>base64_encode($image), 'b'=>$anotherObject));
在iphone端我使用了一些框架,再解码JSON和Base64和它的作品... 谢谢你,如果你有关于这个问题,把它们写下来
也许是一个错字,但'* UIImage的IM = [[UIImage的imageWithData:[ARR objectAtIndex:0];'有三个'['但只一个']' – horatio 2011-06-01 15:05:04
sry ...进入快速。 everthing编译完美,它运行...但图像不能被读取... – 2011-06-01 15:11:22
file_get_contents('$ direction');不可能是正确的。应该是(“$方向”)或只是($方向)。 – Flipper 2011-06-01 15:12:37