<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script><!--
<a target="_blank" href="http://iPhoneDeveloperTips.com?wp_ct=10"><img border="0" src="/images/ads/SnowLeopard.jpg"></a><img src="http://www.assoc-amazon.com/e/ir?t=iphonedevelopertips-20&l=as2&o=1&a=B001AMPP0W" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
-->
<!-- Ad in post --><!--
<div style="float: left; width: 169; height: 76; margin:0px 0px 0px 0px;">
<a href="http://iPhoneDeveloperTips.com?wp_ct=37"><img border="0" src="/images/ads/job-board-ad-link-in-post.png"></a>
</div>
--><!--content with more link-->
This tip will show the steps to download and display an image from a remote resource. This is handy if you need to add an image as a subview, yet, the image is not part of your application bundle.
URL to Remote Image
We start by creating a URL to the remote resource:
NSURL *url = [NSURL URLWithString:
@"http://iphonedevelopertips.com/images/logo-iphone-dev-tips.png"];
Create UIImage from NSData
The next step is to build a UIImage using the data downloaded from the URL, which consists of an NSData object that holds the remote image contents:
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
Putting it Together
Here’s how to wrap it all together, adding the remote image as a subview to an existing view by creating a UIImageView from the above UIImage:
NSURL *url = [NSURL URLWithString:
@"http://iphonedevelopertips.com/images/logo-iphone-dev-tips.png"];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
[self.view addSubview:[[UIImageView alloc] initWithImage:image]];
分享到:
相关推荐
Zip and FTP Upload Selected Files from an existing Zip file • FTP Upload new and existing Zip files • Zip and Burn new and existing Zip files directly to CD and DVD Encryption and Security • FIPS...
Instructions on how to download and install the JavaMail API are contained in the course. In addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard...
It covers all of the classes, methods, and techniques needed to create, manipulate, and display precise graphics in a form, a page being sent to a printer, or an image. On this foundation, the ...
JavaCV also comes with hardware accelerated full-screen image display (CanvasFrame and GLCanvasFrame), easy-to-use methods to execute code in parallel on multiple cores (Parallel), user-friendly ...
除了其强大的功能和方便的使用, 这里还有一些顶尖的技术因素是CuteEditor编辑器成为你编辑和发布Web内容的最佳选择: ... CuteEditor 5.0 lets you easily create image maps to add fun and excitement to a page...
save and restore columns order and display width in ini-files and system registry; display icons for BLOB, memo, OLE and picture fields; select multiple records; convert columns headings to buttons. ...
Download and boot kernel from RAM. flash:raw PARTITION KERNEL [RAMDISK [SECOND]] Create boot image and flash it. --dtb DTB Specify path to DTB for boot image header version 2. --cmdline CMDLINE ...
This occurs because BitBlt doesn't completely display the bitmap during a single screen refresh and therefore the image is partially displayed before the refresh occurs. To get round this problem you...
7) If upgrading from a previous version of the Drag and Drop Component Suite, please read the document "upgrading_to_v4.txt" before you begin working on your existing projects. Note about "Property...
This problem is now just reported as an error (and BurnInTest) continues. - When BurnInTest crashes, it should now generate a "minidump" file to help debug which system component caused the failure...
This fact compromises security in Workgroup environments, and removable media security can also be compromised in networks with multiple identical computer SIDs.Demand from the Windows community has ...
Smaller JAR file sizes can improve application performance by reducing download times and minimizing memory usage. ##### 3.1 Designing for Small Size When designing applications, consider the ...
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it devices list all connected devices reboot reboot device normally reboot-bootloader reboot device into bootloader options: -w erase ...
这通常通过调用`toDataURL`方法获取Canvas的内容作为data URL,然后创建一个新的Image对象并赋值这个URL,等待加载完成后再进行后续处理。 下面是一个简单的示例: ```javascript function canvasToImage(canvas) ...
Create Creates a DIB section of the specified width and height in pixels. CreateFromPicture Creates a DIB section the same size as a VB picture object and copies the bitmap in it into the DIB...
specify an alternative redolog file of USB MSD disk image modes) - hard drive - new disk image mode 'vvfat' - ported the read-only part of Qemu's 'virtual VFAT' block driver - additions: ...
By inputting values of between 0% and 100% in Image Alpha text field, the image goes from fully transparent to fully opaque. 7. Checking for Update This option under the Help menu detects the new ...
of the INI constants (On, Off, True, False, Yes, No and None) or an expression ; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a ; previously set variable or directive (e.g. ${...
If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning. 在使用.htaccess之前...