0

我收到内存警告,因为“引用计数对象在被释放后被使用”

为此,我也尝试过自动释放。但没有用。

下面是给出我警告的代码。问题是什么。请告诉我

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
                [switchView initWithFrame:CGRectMake(180,5,260,30)];
                [switchView setOn:YES];
                mySearchType = 1;
                [[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
                [[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
                [switchView addTarget:self action:@selector(switchToggled:)forControlEvents:UIControlEventValueChanged];
                [cell.contentView addSubview:switchView];
4

1 回答 1

3

更改以下代码

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
                [switchView initWithFrame:CGRectMake(180,5,260,30)];

进入

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectMake(180,5,260,30)];
于 2012-07-21T12:18:49.287 回答