我收到内存警告“引用计数对象在被释放后使用”
为此,我也试过autorelease。但没用。
下面的代码是我发出警告的问题。问题是什么。请告诉我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];
答案 0 :(得分:3)
更改以下代码
UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
[switchView initWithFrame:CGRectMake(180,5,260,30)];
进入
UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectMake(180,5,260,30)];