iOS:在FXForms项目中的tableView中滚动时内存增加

时间:2018-03-30 08:38:46

标签: ios objective-c uitableview fxforms

当我使用FXForms创建表单时,它非常流畅,内存正常。问题是你向下滚动越多,内存越多,滚动速度越慢,非常糟糕。 我在a ticketanother ticket中读到FXForms的桌面视图不使用单元格回收。

如何找到解决该问题的方法?

- (UITableViewCell *)cellForField:(FXFormField *)field
{
    //FIXME: memory leak recycle cells

    //don't recycle cells - it would make things complicated
    Class cellClass = field.cellClass ?: [self cellClassForField:field];
    NSString *nibName = NSStringFromClass(cellClass);
    if ([nibName rangeOfString:@"."].location != NSNotFound)
    {
        nibName = nibName.pathExtension; //Removes Swift namespace
    }
    if ([field.mandatory isKindOfClass:[NSString class]])
    {
        if ([field.mandatory isEqualToString:@"YES"])
        {
            NSString *string = [field.title stringByReplacingOccurrencesOfString:@" " withString:@""];
            BOOL isNotEmpty = ![string isEqualToString:@""];
            if (isNotEmpty)
            {
                if (![[string substringToIndex:1] isEqualToString:mandatoryCharacter])
                {
                    [field setValue: [NSString stringWithFormat:@"%@%@", mandatoryCharacter, field.title] forKey:@"title"];
                }
            }
        }
    }
    if ([[NSBundle mainBundle] pathForResource:nibName ofType:@"nib"])
    {
        //load cell from nib
        return [[[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil] firstObject];
    }
    else
    {
        //hackity-hack-hack
        UITableViewCellStyle style = UITableViewCellStyleDefault;
        if ([field valueForKey:@"style"])
        {
            style = [[field valueForKey:@"style"] integerValue];
        }
        else if (FXFormCanGetValueForKey(field.form, field.key))
        {
            style = UITableViewCellStyleValue1;
        }

        //don't recycle cells - it would make things complicated
        return [[cellClass alloc] initWithStyle:style reuseIdentifier:NSStringFromClass(cellClass)];
    }
}

提前致谢。

1 个答案:

答案 0 :(得分:0)

将您的代码放入autoreleasepool并检查

e.g:

"--secure-port", "443",