我目前正在研究一個ipad項目,並發現這個。 所以這裏是我的結構爲什麼內存仍然保持,當我做removefromsuperview?
我的子類的UIViewController爲customizedVC,這樣
@protocol customizedVCDelegate
-(void)viewclosed:(UIView *)view oldviewcontroller:(UIViewController *)oldvc newvcname:(UIViewController *)newvc;
@end
@interface customizedVC : UIViewController {
id <customizedVCDelegate> delegate;
}
@property (assign) id <customizedVCDelegate> delegate;
@end
在demoipadappDelegate
,這是用於切換視圖的骨幹,我採取了協議並實施了viewclosed功能。 我收到了很多意見,每個視圖都將從筆尖加載。所以我加載第一個在demoipadappDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//loading openvinview
openingVC *vc = [[openingVC alloc] initWithNibName:@"openingview" bundle:nil];
vc.delegate = self;
[window addSubview:vc.view];
[window makeKeyAndVisible];
return YES;
}
要切換的意見,我會觸發viewClosed在每個viewcontroller。例如,我得到了VC1,並想開通VC2。我在vc1中關閉視圖。並且由於vc1的委託是demoipadappDelegate,事實上所有vc的委託都是demoipadappDelegate。所以這個demoipadappDelegate會收到這個事件並執行此操作。這是在demoipadappDelegate
-(void)viewclosed:(UIView *)view oldviewcontroller:(UIViewController *)oldvc newvcname:(UIViewController *)newvc;
{
self.currentVC = (customizedVC *)newvc;
self.currentVC.delegate = self;
[window addSubview:self.currentVC.view];
[view removeFromSuperview];
[oldvc release];
}
我預計memery用法會下降。它沒有。 我也檢查過,在每個VC中,我已經手動釋放任何我分配的東西。所以情況並非如此。
對不起我的英文不好,我希望我已經解釋不夠清楚
是的,外殼是正確的,不是由拼寫造成的,但無論如何感謝 – shawhu 2010-07-19 07:26:18