开发者

Animated Subviews

开发者 https://www.devze.com 2023-03-13 11:59 出处:网络
I have a split view controller in my Ipad app, in which the detail view has subviews which are UITableView\'s.

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.


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.


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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号