• <bdo id='cZfym'></bdo><ul id='cZfym'></ul>

  • <small id='cZfym'></small><noframes id='cZfym'>

    <tfoot id='cZfym'></tfoot>

  • <i id='cZfym'><tr id='cZfym'><dt id='cZfym'><q id='cZfym'><span id='cZfym'><b id='cZfym'><form id='cZfym'><ins id='cZfym'></ins><ul id='cZfym'></ul><sub id='cZfym'></sub></form><legend id='cZfym'></legend><bdo id='cZfym'><pre id='cZfym'><center id='cZfym'></center></pre></bdo></b><th id='cZfym'></th></span></q></dt></tr></i><div id='cZfym'><tfoot id='cZfym'></tfoot><dl id='cZfym'><fieldset id='cZfym'></fieldset></dl></div>
    <legend id='cZfym'><style id='cZfym'><dir id='cZfym'><q id='cZfym'></q></dir></style></legend>

        目标 - C:从 URL 加载图像?

        objective - C : Loading image from URL?(目标 - C:从 URL 加载图像?)

        <small id='Pw3q9'></small><noframes id='Pw3q9'>

          • <bdo id='Pw3q9'></bdo><ul id='Pw3q9'></ul>

              <tbody id='Pw3q9'></tbody>

              • <legend id='Pw3q9'><style id='Pw3q9'><dir id='Pw3q9'><q id='Pw3q9'></q></dir></style></legend>

                  <i id='Pw3q9'><tr id='Pw3q9'><dt id='Pw3q9'><q id='Pw3q9'><span id='Pw3q9'><b id='Pw3q9'><form id='Pw3q9'><ins id='Pw3q9'></ins><ul id='Pw3q9'></ul><sub id='Pw3q9'></sub></form><legend id='Pw3q9'></legend><bdo id='Pw3q9'><pre id='Pw3q9'><center id='Pw3q9'></center></pre></bdo></b><th id='Pw3q9'></th></span></q></dt></tr></i><div id='Pw3q9'><tfoot id='Pw3q9'></tfoot><dl id='Pw3q9'><fieldset id='Pw3q9'></fieldset></dl></div>

                1. <tfoot id='Pw3q9'></tfoot>
                  本文介绍了目标 - C:从 URL 加载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Sorry for question title. I can not find a suitable title.

                  I have UITableView content images from url when i open the UITableView the View did not show until the images loaded and that takes along time.

                  I get the images from JSON by php.

                  I want to show the table and then images loading process.

                  This is code from my app:

                  NSDictionary *info = [json objectAtIndex:indexPath.row];
                  cell.lbl.text = [info objectForKey:@"title"];
                  NSString *imageUrl = [info objectForKey:@"image"];
                  cell.img.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
                  [cell.img.layer setBorderColor: [[UIColor blackColor] CGColor]];
                  [cell.img.layer setBorderWidth: 1.0];
                  
                  return cell;
                  

                  Sorry my english is weak.

                  解决方案

                  Perform the web request on a separate thread, to not block the UI. Here is an example using NSOperation. Remember to only update the UI on the main thread, as shown with performSelectorOnMainThread:.

                  - (void)loadImage:(NSURL *)imageURL
                  {
                      NSOperationQueue *queue = [NSOperationQueue new];
                      NSInvocationOperation *operation = [[NSInvocationOperation alloc]
                                                          initWithTarget:self
                                                          selector:@selector(requestRemoteImage:)
                                                          object:imageURL];
                      [queue addOperation:operation];
                  }
                  
                  - (void)requestRemoteImage:(NSURL *)imageURL
                  {
                      NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL];
                      UIImage *image = [[UIImage alloc] initWithData:imageData];
                  
                      [self performSelectorOnMainThread:@selector(placeImageInUI:) withObject:image waitUntilDone:YES];
                  }
                  
                  - (void)placeImageInUI:(UIImage *)image
                  {
                      [_image setImage:image];
                  }
                  

                  这篇关于目标 - C:从 URL 加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  Difference between retain and copy?(保留和复制的区别?)
                  When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                  Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                  Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)
                2. <tfoot id='baX0c'></tfoot>

                  • <small id='baX0c'></small><noframes id='baX0c'>

                      <tbody id='baX0c'></tbody>

                        <i id='baX0c'><tr id='baX0c'><dt id='baX0c'><q id='baX0c'><span id='baX0c'><b id='baX0c'><form id='baX0c'><ins id='baX0c'></ins><ul id='baX0c'></ul><sub id='baX0c'></sub></form><legend id='baX0c'></legend><bdo id='baX0c'><pre id='baX0c'><center id='baX0c'></center></pre></bdo></b><th id='baX0c'></th></span></q></dt></tr></i><div id='baX0c'><tfoot id='baX0c'></tfoot><dl id='baX0c'><fieldset id='baX0c'></fieldset></dl></div>
                        • <bdo id='baX0c'></bdo><ul id='baX0c'></ul>
                          <legend id='baX0c'><style id='baX0c'><dir id='baX0c'><q id='baX0c'></q></dir></style></legend>