开发者

loading custom view using loadNibNamed showing memory leaks

I have a number of custom table cells and views that I built using interface builder开发者_如何学C

In interface builder, everything is set up similarly. There is a table cell and a couple other UILabels and a background image

Object owner if the nib is NSObject Class for the table cell is the name of the class for my table cell

Here is how I create the table cell in my code:

SectionedSwitchTableCell *cell = nil;
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:kSectionedSwitchTableCellIdentifier owner:owner options:nil];
for(id currentObject in nibs)
{
    if([currentObject isKindOfClass:[SectionedSwitchTableCell class]])
    {
        cell = (SectionedSwitchTableCell *)currentObject;
        break;
    }
}
return cell;

For my custom table headers I have this

    NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"CustomTableHeader" owner:self options:nil];
    for(id currentObject in nibs)
    {
        if([currentObject isKindOfClass:[CustomTableHeader class]])
        {
           return header
        }
    }

In my .h and .m files for the custom view, I have IBOutlet, @property set up for everything except for the background image UIImageView. Everything that has the IBOutlet and @property are also @synthesized and released in the .m file.

Leaks is showing that I have memory leaks with CALayer when I create these custom view objects. Am I doing something wrong here when I create these custom view objects? I'm kind of tearing my hair out trying to figure out where these leaks are coming from.

As a side note, I have a UIImageView background image defined in these custom views but I didn't define properties and IBOutlets in my .h and .m files. Defining them doesn't make a difference when I run it through Leaks but just wanted to confirm if I'm doing the right thing.

Any input would be super helpful. Thanks :)


Check your custom cell xib file, ensure you have set the identifier (kSectionedSwitchTableCellIdentifier) to the cell. I have the similar problem and fixed with this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜