Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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 滚动AQGridView项目时出现延迟_Ios_Xcode_Uiscrollview_Aqgridview - Fatal编程技术网

Ios 滚动AQGridView项目时出现延迟

Ios 滚动AQGridView项目时出现延迟,ios,xcode,uiscrollview,aqgridview,Ios,Xcode,Uiscrollview,Aqgridview,我有一个AQGridView视图,在GridView 12行中有45个项目,当我滚动视图时会出现问题,当创建新行时网格会变长。我正在考虑一次性创建整行,并从缓存或其他地方使用它,而不是每次滚动时都要求创建它,因为它不可用,并且在延迟时看起来也不好。谢谢 - (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) `enter code here`index { NSStr

我有一个AQGridView视图,在GridView 12行中有45个项目,当我滚动视图时会出现问题,当创建新行时网格会变长。我正在考虑一次性创建整行,并从缓存或其他地方使用它,而不是每次滚动时都要求创建它,因为它不可用,并且在延迟时看起来也不好。谢谢

- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) `enter code here`index
{
    NSString *fullThumbPath = [itemsList objectAtIndex:index];
    int startOfThumbWord = [fullThumbPath rangeOfString:@"bundle"].location;
    NSString *shortThumbPath = [fullThumbPath substringFromIndex:startOfThumbWord+7];
    if (
        ([vieta isEqualToString:@"cover"] || [vieta isEqualToString:@""]) && [labelis isEqualToString:@""]) {
        static NSString * PlainCellIdentifier = @"ImageCell";
        AFInstallerImageCell2 * plainCell2 = (AFInstallerImageCell2 *)[aGridView dequeueReusableCellWithIdentifier: PlainCellIdentifier];
            plainCell2 = [[AFInstallerImageCell2 alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0) // 330
                                                    reuseIdentifier: PlainCellIdentifier];

    plainCell2.selectionStyle = AQGridViewCellSelectionStyleNone;
    plainCell2.path = [target stringByAppendingPathComponent:shortThumbPath];//[itemsList objectAtIndex:index];
    plainCell2.image = [UIImage imageWithContentsOfFile:[itemsList objectAtIndex:index]];
    plainCell2.layer.shouldRasterize = YES;
    NSString *shortThumbPath = [fullThumbPath substringFromIndex:startOfThumbWord+30];

    shortThumbPath = [shortThumbPath stringByReplacingOccurrencesOfString:@"/Thumb.png"
                                         withString:@""];

    NSString *title = [[shortThumbPath lastPathComponent] stringByDeletingPathExtension];
    plainCell2.title = [title stringByReplacingOccurrencesOfString:@"_" withString:@" "];
    return ( plainCell2 );
}

这是因为您一次又一次地创建纯素素2

使用tableView/gridview的dequeueReusableCellWithIdentifier,您可以 大大加快了速度。与实例化大量单元格不同,您可以 只需根据需要实例化尽可能多的对象,即尽可能多的可见对象 这是自动处理的。但您正在创建一个新的 时间

替换这个

用这个


你能分享一些你已经实现的代码吗?我想看看你的单元格的索引方法好的,这是我的@IgnasS请编辑你的问题并在那里添加代码。我以前试过这个,它并没有加快速度。无论如何,谢谢你的帮助!这是我在上述代码中看到的唯一问题。如果您正在做的事情与此不同,请也添加它
 AFInstallerImageCell2 * plainCell2 = (AFInstallerImageCell2 *)[aGridView dequeueReusableCellWithIdentifier: PlainCellIdentifier];
            plainCell2 = [[AFInstallerImageCell2 alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0) // 330
                                                    reuseIdentifier: PlainCellIdentifier];
     AFInstallerImageCell2 * plainCell2 = (AFInstallerImageCell2 *)[aGridView dequeueReusableCellWithIdentifier: PlainCellIdentifier];
              if(plainCell2 ==nil) { 
plainCell2 = [[AFInstallerImageCell2 alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0) // 330
                                                        reuseIdentifier: PlainCellIdentifier];
}