简体   繁体   English

如何在iPhone中显示.tiff图像?

[英]How to display .tiff images in iphone?

I want to display .tiff images coming from server in my native iphone application. 我想在本机iphone应用程序中显示来自服务器的.tiff图像。 Is it possible to display .tiff images in native iphone application? 是否可以在本机iphone应用程序中显示.tiff图像? I am trying to solve this problem since 2 hrs with no success. 自2个小时以来,我一直试图解决此问题,但没有成功。 I searched the net for nearly 2 hrs with no solution to this problem. 我在网上搜索了将近2个小时,但仍未解决此问题。

Can anyone help me to solve this problem... 谁能帮我解决这个问题...

Any sample code will be very helpful... 任何示例代码都将非常有帮助...

Thanx in advance... 提前感谢...

Here it says that the tiff format is supported by the UIImage class so you can load it in one of those and put it into an UIImageView . 这里说的是, UIImage类支持tiff格式,因此您可以将其中的一种加载为tiff格式,然后将其放入UIImageView Have you already tried this? 您已经尝试过了吗? If the answer is yes, post some code 如果答案是肯定的,请发布一些代码

Yes. 是。 You can display tiff images coming from the server. 您可以显示来自服务器的tiff图像。 You can load these images into WebView or UIImageView . 您可以将这些图像加载到WebView或UIImageView What you need to do is : 您需要做的是:

You need to encode the data which comes from the server.After encoding the data, you need to add it inside the WebView. 您需要对来自服务器的数据进行编码。对数据进行编码后,需要将其添加到WebView中。 Example : 范例:

NSMutableData *recievedData; // the data coming from the server

......

NSString *str = [receivedData base64Encoding]; //my base64Encoding function

NSData *new_data = [NSData dataWithBase64EncodedString:str]; my function

UIImage *image2 = [UIImage imageWithData:new_data];

[image_view setImage:image2];

[web_view loadData:new_data MIMEType:@"image.tiff" textEncodingName:nil baseURL:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM