我有一個非常簡單的問題。在下面的一段代碼中,將活動指示符放入dealloc會更好嗎,因爲我將它添加到子視圖後開始並停止活動指示符?我應該在dealloc中放置我的活動指示符釋放語句嗎?
- (void)viewDidLoad {
[super viewDidLoad];
// add activity indicator
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = CGPointMake(self.view.bounds.size.width/2.0f, self.view.bounds.size.height/2.0f);
activityIndicator.hidesWhenStopped = YES;
[self.view addSubview:activityIndicator];
[activityIndicator release]; // SHOULD THIS BE PLACED IN DEALLOC?
[self loadFax];
}
viewDidUnload僅在內存警告的情況下被調用,而不是從被釋放的VC中調用......它需要在兩者中完成。 –
@Kendall Helmstetter Gelner:非常感謝!我忘了這個和iOS2,並糾正了我的答案。 – sergio