我的代码很简单给定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?
总结以上是内存溢出为你收集整理的objective-c – 如何使子视图填充其超视图全部内容,希望文章能够帮你解决objective-c – 如何使子视图填充其超视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)