我有在UiTableView上加載的問題我有延遲4秒在4s iphone和9sec 4 iphone。我使用異步下載圖像,速度非常快。緩慢加載UiTableView
-(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我DATAS然後我打電話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;
}
調用'reloadData'後會發生這個問題嗎?顯示你在哪裏調用'reloadData'。確保它在主線程上完成。你的'cellForRowAtIndexPath'沒有問題。 – rmaddy 2014-10-17 14:42:50