【发布时间】:2014-09-03 11:11:11
【问题描述】:
这是我的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"custom";
SampleTableCell*cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[SampleTableCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
User *user = [tableData objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
cell.name_Label.text = user.event_name;
cell.description_Label.text = user.event_description;
cell.venue_Label.text = user.event_venue;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
[[cell imageView] setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:arr[indexPath.row]]]]];
dispatch_sync(dispatch_get_main_queue(), ^{
[[cell imageView] setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:arr[indexPath.row]]]]];
[cell setNeedsLayout];
});
});
return cell;
}
这是我获取数据的委托方法:
-(void)repaint:(NSMutableArray *)retrievedData
{
if (retrievedData.count > 0)
{
userObj = [retrievedData objectAtIndex:0];
for (userObj in retrievedData)
{
NSLog(@"%@is the value",retrievedData);
url_Img1=@"http://kiascenehai.pk/assets/uploads/event-images/50x50-thumb/";
url_Img2=userObj.event_dpURL;
url_Img_FULL = [url_Img1 stringByAppendingPathComponent:url_Img2];
[arr addObject:url_Img_FULL];
NSUserDefaults * userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setObject:userObj.event_dpURL forKey:@"dpURL"];
[userDefault synchronize];
result = [userDefault objectForKey:@"dpURL"];
NSLog(@"Show url_Img_FULL: %@",url_Img_FULL);
[tableData addObjectsFromArray:retrievedData];
[table reloadData];
}
【问题讨论】:
-
当我滚动表格时;它在加载新单元格时显示抽搐。我需要一些方法来改善它的滚动,就像 facebook 应用程序一样。
-
你应该使用SDWebImage 库。它会让你的tableview非常流畅。我自己在很多应用程序中都使用过它..
-
Ahmed Z.但我无法使用它..我是 ios 开发的新手,它超越了我的想法..需要一些其他想法
-
没有其他想法或方法可以让它更流畅......
标签: iphone uitableview ios7