我一直拉我的頭髮在這個問題上,我已閱讀所有關於釋放問題的帖子,但不明白爲什麼,因爲我很新的Objective-C和iPhone,你可以告訴: )UIImage釋放問題
但我不明白的是代碼下面說我已經過度釋放UIImage的,現在我已經嘗試了一切,但應用程序仍然崩潰
UIImage *imageSave = [UIImage imageNamed:@"btn_save.png"];
UIButton *btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
[btnSave setBackgroundImage:imageSave forState:UIControlStateNormal];
btnSave.frame = CGRectMake(0, 0, imageSave.size.width, imageSave.size.height);
[btnSave addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barBtnSave = [[UIBarButtonItem alloc] initWithCustomView:btnSave];
self.navigationItem.rightBarButtonItem = barBtnSave;
//[imageSave release];
//[btnSave release];
[barBtnSave release];
UIImage *imageCancel = [UIImage imageNamed:@"btn_cancel.png"];
UIButton *btnCancel = [UIButton buttonWithType:UIButtonTypeCustom];
[btnCancel setBackgroundImage:imageCancel forState:UIControlStateNormal];
btnCancel.frame = CGRectMake(0, 0, imageCancel.size.width, imageCancel.size.height);
[btnCancel addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barBtnCancel = [[UIBarButtonItem alloc] initWithCustomView:btnCancel];
self.navigationItem.leftBarButtonItem = barBtnCancel;
//[imageCancel release];
//[btnCancel release];
[barBtnCancel release];
即使註釋掉調用「釋放」你有一個問題?還是你想了解爲什麼你必須評論他們? – imaginaryboy 2010-09-15 05:37:57