动画子视图

发布于 2024-11-15 05:27:08 字数 807 浏览 4 评论 0原文

我的 iPad 应用程序中有一个分割视图控制器,其中详细视图具有 UITableView 的子视图。 我试图实现的功能是当按下子视图上的按钮(信息按钮)时,在子视图的同一位置获取信息视图。我需要通过动画获取此信息视图,该动画是当按下信息按钮时,该子视图将单独翻转(UIAnimationOptionFlipFromRight)并且信息视图将显示...

这就是尝试实现它的方法 -

-(void) showInfoView: (id)sender
{

    infoView = [[InfoViewController alloc] initWithNibName:@"ViewViewController" bundle:nil];
    infoView.view.frame = CGRectMake(250, 300, 200, 200);

    [UIView transitionWithView:self.view duration:1
                       options:UIViewAnimationOptionTransitionFlipFromRight 
                    animations:^{
                        [self.view addSubview:infoView.view];
                    } 
                    completion:nil];
}

当我运行模拟器并按任何子视图上的信息按钮,所发生的情况是动画完美地发生,即子视图从右侧翻转但 infoView 没有显示。

如果有人能告诉我我哪里出错了,那就太好了。

I have a split view controller in my Ipad app, in which the detail view has subviews which are UITableView's.
The functionality I am trying to implement is to get an info view at the same position of a subview when a button(info button) on the subview is pressed. I need to get this info view by animation and that animation is that when the info button is pressed, that subview alone would flip (UIAnimationOptionFlipFromRight) and the info view would show...

This is how try to implement it -

-(void) showInfoView: (id)sender
{

    infoView = [[InfoViewController alloc] initWithNibName:@"ViewViewController" bundle:nil];
    infoView.view.frame = CGRectMake(250, 300, 200, 200);

    [UIView transitionWithView:self.view duration:1
                       options:UIViewAnimationOptionTransitionFlipFromRight 
                    animations:^{
                        [self.view addSubview:infoView.view];
                    } 
                    completion:nil];
}

When I run the simulator and press the info button on any subview, what happens is that the animation happens perfectly, i.e. the subview flips from the right but the infoView is not getting displayed.

It would be great if someone could tell me where I am going wrong here.

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

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

发布评论

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

评论(2

能否归途做我良人 2024-11-22 05:27:08

在屏幕上执行动画的基本步骤如下:

  1. 创建视图。
  2. 将其移动到初始(屏幕外)位置
  3. 添加到视图层次结构
  4. 执行动画。

您似乎正在跳过第 3 步,甚至可能跳过第 2 步。

The basic steps of performing an animation to onscreen is as follows:

  1. Create the view.
  2. Move it to the initial (offscreen) position
  3. Add to the view hierarchy
  4. Perform the animation.

It seems like you're skipping step 3 and possibly step 2.

伤感在游骋 2024-11-22 05:27:08

您是否尝试将子视图框架设置为超级视图的框架,即

 info.View.frame = self.view.frame;

Did you try setting the subview frame to the frame of your superview, i.e

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