我在调用手机自带相机的时候出现了内存泄露,代码如下UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.allowsEditing = NO; if (sender.tag == 1)
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
[imagePicker setDelegate:self]; NSLog(@"picker retaincount1 %i",[imagePicker retainCount]);
[self presentModalViewController:imagePicker animated:YES]; NSLog(@"picker retaincount2 %i",[imagePicker retainCount]);控制台输出的是picker retaincount1 1picker retaincount2 4
1 回答
喵喵时光机
TA贡献1846条经验 获得超7个赞
这很正常,presentModalViewController
这个方法会retain传给它的view controller参数,至于retain几次,跟它内部具体实现相关。开发者没必要关心这些,只要你保证自己主动调用的alloc和release相匹配就可以了,剩下的交给系统去处理。
- 1 回答
- 0 关注
- 223 浏览
添加回答
举报
0/150
提交
取消