objective-c – 如何使子视图填充其超视图

在这里找不到答案,也没有看到重复的问题.

我的代码很简单给定3个UIView,parent,from和to,从父中删除添加子视图.添加动画,但只是doodads.

现在,问题是当我这样做,然后被抵消.就好像被推倒了

我甚至添加To.frame = ParentView.frame;以确保它有效.没有

我该怎么做?

+ (void) AnimateSwitchingWithParent: (UIView *) ParentView From: (UIView *) From To: (UIView* ) To
{
    /*[UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];


    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromright forView:ParentView cache:YES];*/
    [From removeFromSuperview];
    [ParentView addSubview:To];

    To.frame=ParentView.frame; //If I don't do this,the subview is still off by around 20 points
    NSLog(@"To.bounds: %@",NsstringFromCGRect(To.bounds));
    NSLog(@"From.bounds.: %@",NsstringFromCGRect(From.bounds));
    NSLog(@"ParentView.bounds: %@",NsstringFromCGRect(ParentView.bounds));


    //JA_DUMP (To.bounds);
    //JA_DUMP (To.bounds);



    /*[UIView commitAnimations];*/

}

我已经弄清楚了解决方案.结束To的框架

To.frames:{{0,0},{320,372}}

但是,如果我删除To.frame = ParentView.frame框架也是

{{0,20},460}}

我想知道为什么? 20点似乎是状态栏的距离.我们在哪里可以在InterfaceBuilder中设置该框架?

我在SimulatedMetric部分中将statusbar设置为none.

解决方法

似乎你误解了框架和边界,将你的代码修改为To.frame = ParentView.bounds;应该可以.

相关:Why is there an frame rectangle and an bounds rectangle in an UIView?

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...