内存泄漏使用datePicker.datePickerMode

时间:2015-06-09 14:07:15

标签: ios objective-c memory-leaks datepicker

我正在创建一个包含日期选择器的自定义视图。我的应用程序运行缓慢,仪器显示我有内存泄漏。导致泄漏的线是:

datePicker.datePickerMode = UIDatePickerModeDate;

任何帮助将不胜感激,我不知道为什么这会导致泄漏。整个方法如下。

- (UIView *)createDemoView
{
    UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 260)];
    CGRect rect = CGRectMake(0, 0, 280, 60);
    UITextView *textView = [[UITextView alloc] initWithFrame:rect];
    textView.backgroundColor=[UIColor clearColor];
    textView.font = [UIFont fontWithName:@"Cochin" size:13];
    textView.text = @"Please Enter Your Birthday";
    textView.textAlignment = NSTextAlignmentLeft;
    UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(-18,50,162,162)]; //-10.0f, 40.0f, 130.0f, 200.0f)];
    datePicker.datePickerMode = UIDatePickerModeDate;
    [datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    [demoView addSubview:textView];
    [demoView addSubview:datePicker];
    return demoView;
}

0 个答案:

没有答案