0

我正在寻找一种将图像从磁盘加载到 CPImageView 的方法。这可能吗?

4

1 回答 1

1

要将图像上传到服务器,您可以使用普通的文件上传按钮,例如FileUpload. 或者,如果您不害怕一些潜在的非常棘手的跨浏览器问题,您可以尝试使用我的Deep Drop Upload允许拖放上传的 fork。

无论哪种情况,一旦图像在您的服务器上,您需要您的服务器返回可以查看图像的 URL。假设这个 URL 是http://example.com/uploads/image101.png. 然后就可以CPImageView正常显示了:

var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[imageView setImage:[[CPImage alloc] initWithContentsOfFile:"http://example.com/uploads/image101.png"]];
于 2012-02-08T16:43:13.510 回答