我似乎有一個泄漏的UIDatePicker。我注意到設置datePickerMode顯示日期和時間的內存泄漏。但是,我只是想顯示日期。我相當肯定這是一個框架泄漏,因爲當我註釋掉幾個UIDatePicker屬性分配時,泄漏消失了。此代碼泄漏1個CGColor對象,1個UIDeviceRGBColor對象:UIDatePicker泄漏
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;
通過註釋工具報告違規行,我沒有得到任何泄漏:
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是一文不值。有沒有人有解決方法?
您是否檢查了設備上的泄漏?或只在模擬器上?有時候模擬器會有內存泄漏問題,這在設備上不存在。 – barley
您使用ARC嗎? – Kevin
關於解決方法,泄漏有多嚴重? –