如何在 iPhone 中左翻转动画时停止动画和滑动子视图?

发布于 2024-12-28 23:45:25 字数 1231 浏览 0 评论 0原文

我正在使用以下代码在 iPhone 应用程序中从一个视图导航到另一个视图。

-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
   //[self.navigationController pushViewController:vc animated:YES];
   // [vc release];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }


    [self.view addSubview:vc.view];
    [UIView commitAnimations];

}


-(IBAction)navigateToMainScreen:(id)sender
{ 
    MainVC *vc=[[MainVC alloc]init];


    [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [UIView setAnimationDuration:1.0];
      self.view.backgroundColor=[UIColor blackColor];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }

    [self.view addSubview:vc.view];
    [UIView commitAnimations];

}

但它也会随主视图一起滑动子视图,例如导航栏按钮项目、按钮等。如何防止子视图更改其位置 ?

i am using following code for navigating from one view to another view in iphone app.

-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
   //[self.navigationController pushViewController:vc animated:YES];
   // [vc release];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }


    [self.view addSubview:vc.view];
    [UIView commitAnimations];

}


-(IBAction)navigateToMainScreen:(id)sender
{ 
    MainVC *vc=[[MainVC alloc]init];


    [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    [UIView setAnimationDuration:1.0];
      self.view.backgroundColor=[UIColor blackColor];
    for(UIView *view1 in self.view.subviews)
    {
        [view1 removeFromSuperview];
    }

    [self.view addSubview:vc.view];
    [UIView commitAnimations];

}

But it slides subviews like uinavigation bar button item,button etc also along with the main view.How to prevent subviews from changing their positions
?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日情怀 2025-01-04 23:45:25
This solved the issue.


-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.window cache:YES];
    [UIView commitAnimations];
  [self.navigationController pushViewController:vc animated:YES];
    [vc release];


}
This solved the issue.


-(IBAction)navigateToInfo:(id)sender
{
    InfoDetailViewController *vc=[[InfoDetailViewController alloc]init];
    self.view.backgroundColor=[UIColor blackColor];
      [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.window cache:YES];
    [UIView commitAnimations];
  [self.navigationController pushViewController:vc animated:YES];
    [vc release];


}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文