我似乎有一个泄漏的 UIDatePicker。我已经注意到将 datePickerMode 设置为显示日期和时间的内存泄漏。但是,我只是想显示日期。我相当肯定这是一个框架泄漏,因为当我注释掉几个 UIDatePicker 属性分配时,泄漏就消失了。此代码泄漏 1 个 CGColor 对象和 1 个 UIDeviceRGBColor 对象:
datePicker = [[UIDatePicker alloc] initWithFrame:[self detailViewRect]];
datePicker.datePickerMode = UIDatePickerModeDate; //leaks CGColor when setting this
datePicker.hidden = NO;
datePicker.timeZone = [NSTimeZone systemTimeZone]; //leaks UIDeviceRGBColor
datePicker.maximumDate = [NSDate date];//leaks UIDeviceRGBColor
datePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
通过评论 Instruments 报告为有问题的行,我没有发现任何泄漏:
datePicker = [[UIDatePicker alloc] initWithFrame:[self detailViewRect]];
//datePicker.datePickerMode = UIDatePickerModeDate; //leaks CGColor when setting this
datePicker.hidden = NO;
//datePicker.timeZone = [NSTimeZone systemTimeZone]; //leaks UIDeviceRGBColor
//datePicker.maximumDate = [NSDate date];//leaks UIDeviceRGBColor
datePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
如果至少没有设置日期模式,则 UIDatePicker 毫无价值。有人有解决方法吗?