2011-11-28 74 views
-1
XYZAppDelegate *appdelegate=[[UIApplication sharedApplication] delegate]; 
CSelectorViewController *cPrice=[[CSelectorViewController alloc] initWithNibName:@"CSelectorViewController" bundle:nil]; 
[cPrice.view setFrame:CGRectMake(0, 20, 320, 480)]; 
[appdelegate.window addSubview:cPrice.view]; 

[self applyAnimation]; 
[cPrice release]; 

我加入这样的图,不使用navigationcontroller,因为我必须切换两个视图当我给予[cPrice释放]上下also.but;该应用程序崩溃。但是当我没有在代码中给它...静态分析器显示警告什么是正确的方式来做到这一点?切换两个视图导致崩溃

-(void)applyAnimation 
{ 
    CATransition *animation = [CATransition animation]; 
    [animation setDuration:0.5]; 
    [animation setType:kCATransitionPush]; 
    [animation setSubtype:kCATransitionFromRight]; 
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
    XYZAppDelegate *appdelegate=[[UIApplication sharedApplication] delegate]; 
    [[appdelegate.window layer] addAnimation:animation forKey:@"slideLeft"]; 
} 
+0

与什么错误崩溃?控制台中有什么? –

+0

发送到释放实例的消息...我知道它由于内存问题,只是想知道什么是正确的方式来做...没有内存泄漏 – sujith1406

回答

0

您要添加cPrice的view到窗口作为一个子视图(这将隐含保留的观点),但是你什么都不做保存cPrice本身。你应该把它作为一个保留的财产或一些这样的。