我在UiTableView上加载有问题我在4s iphone和9sec 4 iphone上有4秒延迟。我使用Async下载图像,速度非常快。
-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"item2";
NSLog(@"loading");
MenuCell *cells = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSLog(@"1");
cells.Title.text=[name objectAtIndex:indexPath.row];
[cells.Title setTextColor:[UIColor colorWithRed:(red/255.f) green:(green/255.f) blue:(blue/255.f) alpha:1.0f]];
NSLog(@"2");
NSLog(@"3");
[cells.Image setImageWithURL:[NSURL URLWithString:[page_icon objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@"clickgatemikro.png"]];
NSLog(@"4");
return cells;
}
我的输出:(4秒延迟):
2014-10-17 17:28:19.504 Accounting[501:53015] numberOfRowsInSection TABLE COUNT : 12
2014-10-17 17:28:19.513 Accounting[501:53015] numberOfRowsInSection TABLE COUNT : 12
2014-10-17 17:28:19.515 Accounting[501:53015] loading
2014-10-17 17:28:23.609 Accounting[501:53015] 1
2014-10-17 17:28:23.611 Accounting[501:53015] 2
2014-10-17 17:28:23.612 Accounting[501:53015] 3
2014-10-17 17:28:23.624 Accounting[501:53015] 4
2014-10-17 17:28:23.625 Accounting[501:53015] loading
2014-10-17 17:28:23.635 Accounting[501:53015] 1
2014-10-17 17:28:23.635 Accounting[501:53015] 2
2014-10-17 17:28:23.636 Accounting[501:53015] 3
2014-10-17 17:28:23.638 Accounting[501:53015] 4
2014-10-17 17:28:23.639 Accounting[501:53015] loading
2014-10-17 17:28:23.645 Accounting[501:53015] 1
2014-10-17 17:28:23.651 Accounting[501:53015] 2
2014-10-17 17:28:23.652 Accounting[501:53015] 3
2014-10-17 17:28:23.654 Accounting[501:53015] 4
2014-10-17 17:28:23.698 Accounting[501:53015] FINISH
----------更新-------------
这是我的代码我使用plist在我的Mutablearray上加载我的数据,然后我调用reloadData
- (void)viewDidLoad {
[super viewDidLoad];
[self initVariables];
[self initplist];
self.mytableview.delegate = self;
self.mytableview.dataSource = self;
name = [plistDict objectForKey:@"title"];
image= [plistDict objectForKey:@"image"];
[self.mytableview reloadData];
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSLog(@" numberOfRowsInSection TABLE COUNT : %lu",(unsigned long)[name count]);
return [name count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
答案 0 :(得分:0)
当您想要显示来自URL的图像时,请使用Async,因为它阻止了同步模式下的页面绘制,在图像dl期间使用占位符并将占位符替换为图像。