从水平视图切换导致iPhone应用程序崩溃

问题描述:

这是我的问题: - 我有一个navcontroller,里面有一个带4视图控制器的tabbar控制器。 - 我想增加以下功能: - 在landscapeRight辞退navcontroller,的TabBar控制器以及一切和加载全新的控制器 - 这种人去好了,这里是代码:从水平视图切换导致iPhone应用程序崩溃

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    // Just delete the lines for the orientations you don't want to support 
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
      [appDelegate ToHorizontalAverageResponseView:self]; 
    } 
    return YES; 
} 

这里是在代码应用委托:

- (void)ToHorizontalAverageResponseView:(id)sender 
{ 
    HorizontalResponseViewController *tempController = [[HorizontalResponseViewController alloc] initWithNibName:nil bundle:nil]; 
    [self setHorizontalResponseViewController: tempController]; 
    [tempController release]; 
    //[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; 
    // View rotation transformation 
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(M_PI * 90.0/180.0); 
    [[horizontalResponseViewController view] setTransform:landscapeTransform]; 

    [window addSubview:[horizontalResponseViewController view]]; 
} 

问题是如何转回到纵向视图和所有那些导航栏和标签栏控制器?

THX, 姆拉登

这听起来像你正在试图建立沿与iPod的CoverFlow过渡线的东西。在斯坦福大学的CS193P讲座中提出了一个问题(关于如何构建覆盖流效应),并在以下方面提供了答案:

如果您可以承担内存开销,那么添加新的横向视图可能是最好的在所有的portait视图之上(而不是像你所建议的那样丢弃它们)。用户然后根据需要与该横向视图进行交互,直到返回肖像。所有这一次,肖像的意见都保持在背景中。

+0

我不记得它是哪一个讲座,但它是前六个之一。他们可以在iTunes U上找到视频。 – Hauke 2009-09-16 12:22:21