下面是我的代码..
TestTemp1ViewController *temp=[[TestTemp1ViewController alloc]init];
[self.view addSubview:temp.view];
[self presentModalViewController:temp animated:FALSE];
此代码在 iOS 5.0 中运行良好,但在 iOS 6.0 中崩溃。
Crash report: [UIViewController loadViewIfRequired]-- bad excess
我不明白为什么这在 iOS 6.0 中不起作用。伙计们,我知道这不是好方法,但我想做的是用增长和收缩动画呈现 View Controller 。如果我在展示后执行此操作,那么我将获得 View Controller 的白色背景。
下面是我的代码...
-(void)animateGrowAndShrink:(ViewController *)controller1 {
//self.view.userInteractionEnabled=NO;
[self.view addSubview:controller1.view];
[self presentModalViewController:self.controller animated:FALSE];
if (dayTimeLineIsShown) {
//shrink dayTimeLineIsShown=FALSE;
[UIView beginAnimations:@"animationShrink" context:NULL];
[UIView setAnimationDuration:.61f];
controller1.view.transform=CGAffineTransformMakeScale(.01f,.01f);
} else {
//expand dayTimeLineIsShown=TRUE;
controller1.view.transform=CGAffineTransformMakeScale(0.01,0.01);
[UIView beginAnimations:@"animationExpand" context:NULL];
[UIView setAnimationDuration:.60f];
timeLine.view.transform=CGAffineTransformMakeScale(1, 1);
}
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
}
-(void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context{
self.view.userInteractionEnabled=YES;
if ([animationID isEqualToString:@"animationExpand"]) {
[self presentModalViewController:self.controller1 animated:FALSE];
} else {
self.controller.view.hidden=true;
}
}.
如果我删除它,那么我正在执行此操作的 Controller 也会以模态方式呈现,然后它可以在 ios 6 中工作。实现缩放和缩小的任何其他想法。
最佳答案
-presentModalViewController
和 -addSubview
完全不同,它们不应该一起使用。请参阅:When should I use the addSubview method of a view controller?
我认为删除第二行或第三行会消除错误。
关于ios - 在呈现之前添加 View Controller View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14603318/