故事板中的ios Lazytable图像

故事板中的ios Lazytable图像,ios,Ios,如何将iphone lazytableimages从.xib文件转换为使用故事板?或者任何使用故事板的示例代码,它们与lazytableimages类似。来自的源代码控制器的视图来自哪里并不重要,无论是xib、代码还是情节提要。在该示例中,控制器的代码不会更改,只需确保将场景放在情节提要上,设置其视图控制器类并连接所有插座。无论控制器的视图来自哪里,无论是xib、代码还是情节提要。在该示例中,控制器的代码不会更改,只需确保将场景放在故事板上,设置其视图控制器类并连接所有插座。谢谢您的回复。我已成

如何将iphone lazytableimages从.xib文件转换为使用故事板?或者任何使用故事板的示例代码,它们与lazytableimages类似。来自

的源代码控制器的视图来自哪里并不重要,无论是xib、代码还是情节提要。在该示例中,控制器的代码不会更改,只需确保将场景放在情节提要上,设置其视图控制器类并连接所有插座。

无论控制器的视图来自哪里,无论是xib、代码还是情节提要。在该示例中,控制器的代码不会更改,只需确保将场景放在故事板上,设置其视图控制器类并连接所有插座。

谢谢您的回复。我已成功转到情节提要。但是,在我向下滚动并再次向上滚动之前,图像不会从初始加载的屏幕上显示,然后仅显示图像。如果向下滚动以加载新记录,则可以显示图像。有什么办法解决这个问题吗?听起来好像你丢失了重新加载的数据或重新加载的数据。。。某处。发布您的视图控制器代码。感谢您的回复。我已成功转到情节提要。但是,在我向下滚动并再次向上滚动之前,图像不会从初始加载的屏幕上显示,然后仅显示图像。如果向下滚动以加载新记录,则可以显示图像。有什么办法解决这个问题吗?听起来好像你丢失了重新加载的数据或重新加载的数据。。。某处。发布视图控制器代码。
#import "MasterListViewController.h"
#import "AppRecord.h"
#import "RootViewController.h"
#import "ParseOperation.h"

#define kCustomRowHeight    60.0
#define kCustomRowCount     7

static NSString *const TopPaidAppsFeed =
@"http://phobos.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/limit=75/xml";

@interface MasterListViewController ()
- (void)startIconDownload:(AppRecord *)appRecord forIndexPath:(NSIndexPath *)indexPath;
@end

@implementation MasterListViewController

@synthesize entries;
@synthesize imageDownloadsInProgress;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.imageDownloadsInProgress = [NSMutableDictionary dictionary];
    self.tableView.rowHeight = kCustomRowHeight;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

    NSArray *allDownloads = [self.imageDownloadsInProgress allValues];
    [allDownloads makeObjectsPerformSelector:@selector(cancelDownload)];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int count = [entries count];

    if (count == 0)
    {
        return kCustomRowCount;
    }
    return count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // customize the appearance of table view cells
    //
    static NSString *CellIdentifier = @"LazyTableCell";
    static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";

    // add a placeholder cell while waiting on table data
    int nodeCount = [self.entries count];

    //NSLog(@"RootViewController - nodeCount is %d",nodeCount);

    if (nodeCount == 0 && indexPath.row == 0)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
        if (cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                           reuseIdentifier:PlaceholderCellIdentifier];
            cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }

        cell.detailTextLabel.text = @"Loading…";

        return cell;
    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                       reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    // Leave cells empty if there's no data yet
    if (nodeCount > 0)
    {
        // Set up the cell...
        AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];

        cell.textLabel.text = appRecord.appName;
        cell.detailTextLabel.text = appRecord.artist;

        // Only load cached images; defer new downloads until scrolling ends
        if (!appRecord.appIcon)
        {
            if (self.tableView.dragging == NO && self.tableView.decelerating == NO)
            {
                [self startIconDownload:appRecord forIndexPath:indexPath];
            }
            // if a download is deferred or in progress, return a placeholder image
            cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];
        }
        else
        {
            cell.imageView.image = appRecord.appIcon;
        }

    }

    return cell;
}


- (void)startIconDownload:(AppRecord *)appRecord forIndexPath:(NSIndexPath *)indexPath
{
    IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
    if (iconDownloader == nil)
    {
        iconDownloader = [[IconDownloader alloc] init];
        iconDownloader.appRecord = appRecord;
        iconDownloader.indexPathInTableView = indexPath;
        iconDownloader.delegate = self;
        [imageDownloadsInProgress setObject:iconDownloader forKey:indexPath];
        [iconDownloader startDownload];
    }
}

- (void)loadImagesForOnscreenRows
{
    if ([self.entries count] > 0)
    {
        NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
        for (NSIndexPath *indexPath in visiblePaths)
        {
            AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];

            if (!appRecord.appIcon) // avoid the app icon download if the app already has an icon
            {
                [self startIconDownload:appRecord forIndexPath:indexPath];
            }
        }
    }
}

// called by our ImageDownloader when an icon is ready to be displayed
- (void)appImageDidLoad:(NSIndexPath *)indexPath
{
    IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
    if (iconDownloader != nil)
    {
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:iconDownloader.indexPathInTableView];

        // Display the newly loaded image
        cell.imageView.image = iconDownloader.appRecord.appIcon;
    }

    // Remove the IconDownloader from the in progress list.
    // This will result in it being deallocated.
    [imageDownloadsInProgress removeObjectForKey:indexPath];
}


// Load images for all onscreen rows when scrolling is finished
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (!decelerate)
    {
        [self loadImagesForOnscreenRows];
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    [self loadImagesForOnscreenRows];
}

@end