Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在每个单元格上滚动表格时,视差uiviewcontroller卡滞_Ios_Objective C_Uitableview_Ios7 - Fatal编程技术网

Ios 在每个单元格上滚动表格时,视差uiviewcontroller卡滞

Ios 在每个单元格上滚动表格时,视差uiviewcontroller卡滞,ios,objective-c,uitableview,ios7,Ios,Objective C,Uitableview,Ios7,我正在开发一个应用程序,它将以视差样式的UITableView从服务器加载远程数据。它可以完美地加载数据,但我无法无缝地滚动表格,滚动时它会卡在视图中出现的每个单元格上。这是我的代码,表中只有10个条目。谢谢 - (void)viewDidLoad { [self hasInternet]; self.tableView.dataSource = self; self.tableView.delegate = self; [self loadData];

我正在开发一个应用程序,它将以视差样式的UITableView从服务器加载远程数据。它可以完美地加载数据,但我无法无缝地滚动表格,滚动时它会卡在视图中出现的每个单元格上。这是我的代码,表中只有10个条目。谢谢

- (void)viewDidLoad
{
    [self hasInternet];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self loadData];
    self.edgesForExtendedLayout=UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars=NO;
    self.automaticallyAdjustsScrollViewInsets=NO;
    [super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
    [self scrollViewDidScroll:nil];
    [super viewWillAppear:animated];
    [self loadData];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
}
- (void) loadData{
    name = @"name";
    email = @"email";
    thumbnail = @"thumbnail";
    myObject = [[NSMutableArray alloc] init];
    NSData *jsonSource = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://URL.php"]];
    id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonSource options:NSJSONReadingMutableContainers error:nil];
    for (NSDictionary *dataDict in jsonObjects) {
        NSString *title_data = [dataDict objectForKey:@"fname"];
        NSString *title_data2 = [dataDict objectForKey:@"lname"];
        NSString *fulname = [NSString stringWithFormat:@"%@ %@", title_data, title_data2];
        NSString *emAil = [dataDict objectForKey:@"email"];
        NSString *thumbnail_data = [dataDict objectForKey:@"img"];
        thumbnail_data = [NSString stringWithFormat:@"http://URL/upload/%@",thumbnail_data];
        dictionary = [NSDictionary dictionaryWithObjectsAndKeys: fulname, name, emAil, email, thumbnail_data, thumbnail, nil];
        [myObject addObject:dictionary];
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return myObject.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"parallaxCell";
    JBParallaxCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell=[[UITableViewCell alloc]initWithStyle:
              UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    NSDictionary *tmpDict = [myObject objectAtIndex:indexPath.row];
    NSMutableString *text;
    text = [NSMutableString stringWithFormat:@"%@",[tmpDict objectForKeyedSubscript:name]];
    NSMutableString *mail;
    mail = [NSMutableString stringWithFormat:@"%@",[tmpDict objectForKeyedSubscript:email]];
    NSMutableString *images;
    images = [NSMutableString stringWithFormat:@"%@ ",[tmpDict objectForKey:thumbnail]];
    NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:thumbnail]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc]initWithData:data];
    cell.titleLabel.text = [NSString stringWithFormat:@"%@",text];
    cell.subtitleLabel.text = [NSString stringWithFormat:@"%@",mail];
    cell.parallaxImage.image = img;
    return cell;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSArray *visibleCells = [self.tableView visibleCells];    
    for (JBParallaxCell *cell in visibleCells) {
        [cell cellOnTableView:self.tableView didScrollOnView:self.view];
    }
}

看起来您有一个严重的性能问题,我想这是因为以下代码片段:

NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:thumbnail]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc]initWithData:data]; 
这应该在UI线程之外完成!一旦你在后台下载数据,当抓取完成后,更新UI,你的滚动问题就会消失

对于延迟加载(下载)图像,github上有多个库(或库附带的UIImageView类别)

我写了一篇文章,提到了像你这样的问题

最简单的解决方案是(类似于此,但仍然考虑使用我提到的库来获得更好的效果,您可以设置一些占位符等):


看起来您有一个严重的性能问题,我想这是因为以下代码片段:

NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:thumbnail]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc]initWithData:data]; 
这应该在UI线程之外完成!一旦你在后台下载数据,当抓取完成后,更新UI,你的滚动问题就会消失

对于延迟加载(下载)图像,github上有多个库(或库附带的UIImageView类别)

我写了一篇文章,提到了像你这样的问题

最简单的解决方案是(类似于此,但仍然考虑使用我提到的库来获得更好的效果,您可以设置一些占位符等):


看起来您有一个严重的性能问题,我想这是因为以下代码片段:

NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:thumbnail]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc]initWithData:data]; 
这应该在UI线程之外完成!一旦你在后台下载数据,当抓取完成后,更新UI,你的滚动问题就会消失

对于延迟加载(下载)图像,github上有多个库(或库附带的UIImageView类别)

我写了一篇文章,提到了像你这样的问题

最简单的解决方案是(类似于此,但仍然考虑使用我提到的库来获得更好的效果,您可以设置一些占位符等):


看起来您有一个严重的性能问题,我想这是因为以下代码片段:

NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:thumbnail]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc]initWithData:data]; 
这应该在UI线程之外完成!一旦你在后台下载数据,当抓取完成后,更新UI,你的滚动问题就会消失

对于延迟加载(下载)图像,github上有多个库(或库附带的UIImageView类别)

我写了一篇文章,提到了像你这样的问题

最简单的解决方案是(类似于此,但仍然考虑使用我提到的库来获得更好的效果,您可以设置一些占位符等):



这在那里是非常错误的
NSData*data=[NSData dataWithContentsOfURL:url]
请参阅下面我的建议:)为什么不使用
SDWebImage
处理图像?这在那里是非常错误的
NSData*data=[NSData dataWithContentsOfURL:url]
请参阅下面我的建议:)为什么不使用
SDWebImage
处理图像?这在那里是非常错误的
NSData*data=[NSData dataWithContentsOfURL:url]
请参阅下面我的建议:)为什么不使用
SDWebImage
处理图像?这在那里是非常错误的
NSData*data=[NSData dataWithContentsOfURL:url]请参阅下面的我的建议:“为什么不使用<代码> SDWebImage <代码>图片?它工作得很好,但是现在的第一个和最后一个记录都保持着彼此的切换。考虑使用一些库来从网络中延迟加载图像,添加一个占位符或者添加在自己的位置上。它工作得很好,但是现在是第一个和最后一个记录保存。考虑使用一些库来从Web中延迟加载图像,并有可能添加占位符或将它们添加到您自己的网络中。它工作良好,但现在的第一个和最后一个记录彼此保持切换。考虑使用一些库来从Web中延迟加载图像,并有可能增加占位符或添加占位符。把它们添加到你自己的。它运行良好,但现在的第一个和最后一个记录保持彼此切换。考虑使用一些库来从网络中延迟加载图像,有可能添加占位符或者自己添加它们。