小编use*_*762的帖子

tableView单元格图像在您快速滚动时异步加载闪烁

我使用异步块(Grand central dispatch)来加载我的单元格图像.但是,如果你快速滚动它们仍然会出现但速度非常快,直到它加载了正确的一个.我确定这是一个常见的问题,但我似乎无法找到它.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];


// Load the image with an GCD block executed in another thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[[appDelegate offersFeeds] objectAtIndex:indexPath.row] imageurl]]];

    dispatch_async(dispatch_get_main_queue(), ^{

        UIImage *offersImage = [UIImage imageWithData:data];

        cell.imageView.image = offersImage;
    });
});

cell.textLabel.text = [[[appDelegate offersFeeds] objectAtIndex:indexPath.row] title];
cell.detailTextLabel.text = [[[appDelegate offersFeeds] objectAtIndex:indexPath.row] subtitle];

return cell;
}
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview uiimageview ios

10
推荐指数
1
解决办法
1万
查看次数

使用MKAnnotationView委托时,引脚已消失

我调用了我的MKAnnotationView委托方法,因为我可以看到我的NSLog输出.但是这些引脚没有出现在地图上.这里有什么我想念的吗?

MapViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MapViewController : UIViewController <MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *nearbyMapView;
@end
Run Code Online (Sandbox Code Playgroud)

MapViewController.m

#import "MapViewController.h"
#import "AppDelegate.h"

@interface MapViewController ()

@end

@implementation MapViewController
AppDelegate *appDelegate;

- (void)viewDidLoad
{
    [super viewDidLoad];    
    appDelegate=[[UIApplication sharedApplication] delegate];
    CLLocationCoordinate2D center = CLLocationCoordinate2DMake(54.995184, -1.566699);
    MKCoordinateSpan span = MKCoordinateSpanMake(0.5, 0.5);
    MKCoordinateRegion regionToDisplay = MKCoordinateRegionMake(center, span);
    [self.nearbyMapView setRegion: regionToDisplay];

    for (int i = 0; i < [[appDelegate offersFeeds] count]; i++) {
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        NSString *plotAddress = [[[appDelegate offersFeeds] …
Run Code Online (Sandbox Code Playgroud)

objective-c mapkit mkannotationview ios

2
推荐指数
1
解决办法
3923
查看次数

如何在tableView之前添加“正在加载”视图控制器

我希望在tableView加载之前有一个“正在加载”视图控制器。您可以推荐执行此操作的最佳方法吗?如果可能,请提供一些代码。

理想情况下,加载屏幕将具有活动指示和标有加载的标签。

在UITableView上方添加一个UIView。

在此处输入图片说明

objective-c uitableview uiactivityindicatorview ios

0
推荐指数
1
解决办法
3930
查看次数