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 release]时;应用程序崩溃。但是当我没有在代码中给它时...静态分析仪正在显示警告......这是正确的方法吗?
-(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)
您将cPrice的view
添加到窗口作为子视图(将隐式保留视图),但您无法保留cPrice本身。你应该把它作为保留财产或其他一些财产。