【问题标题】:PresentModalViewController or addsubview?PresentModalViewController 或 addsubview?
【发布时间】:2011-03-11 15:09:44
【问题描述】:

您好,我正在用 xcode 3.2.3 编写一个应用程序。我想做的就是切换到另一个视图,但我不确定最好的方法。这两种方法中的任何一种我都可以做到...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:screen animated:YES];

[screen release];

或使用...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.0];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[self.view addSubview:screen.view]; 

[UIView commitAnimations];

我对这两种方法都有一些问题。如果我使用 presentModalViewController 并在 PreferencesViewController 中模拟内存警告,我的应用程序就会崩溃。第二种方法不是这种情况。然而,第二种方法使我的按钮在翻转动画期间看起来很奇怪。

谁能告诉我哪里出了问题和/或告诉我哪种方法是正确的

谢谢

【问题讨论】:

    标签: views flip addsubview presentmodalviewcontroller


    【解决方案1】:

    你可以尝试这样做,别忘了释放:

    [self.navigationController pushViewController:[[YourViewController alloc]    initWithNibName:nil bundle:nil] animated:YES];   
    

    【讨论】:

      【解决方案2】:

      PresentModalViewController:-

      YourViewController *vC = [YourViewController alloc]initWithNibName:@"YourViewController" bundle:nil];
      vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
      [self presentModalViewController:vC animated:YES];
      [vC release];
      

      这对我来说很好用

      试试这个代码。一切顺利

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-10
        • 2011-01-17
        • 2011-04-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多