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

为此,我也尝试了自动发行。但没有用。

以下是发出警告的代码。问题是什么。请让我知道

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];

最佳答案

更改以下代码

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


进入

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

10-04 15:50