我使用两个块动态地在子视图上绘制一些按钮。一个计算纵向模式的帧,另一个计算横向。它运作良好,但是当我旋转时,它会覆盖旧的。因此,我的一些按钮来了两次。这是我的代码检测oriantation:如何在绘制前清除子视图的内容
//i have defined blocks in viewDidLoad: and everything is ok till here
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
dispatch_async(dispatch_get_main_queue(), PortraitBlock);
}
else
{
dispatch_async(dispatch_get_main_queue(), LandscapeBlock);
}
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
现在,我该如何清理视图我添加按钮?
注:我补充一个UIView对象上的按钮,而该对象也就是一个UIScrollView对象
@illis如果按钮被添加了两次,然后给按钮添加标签并检查按钮是否存在然后dnt添加它 – Leena 2012-03-30 13:45:45
每次旋转设备时都不需要重新绘制按钮。只要将它们移动到合适的位置并在需要时改变外观。 – SVGreg 2012-03-30 13:55:30
@SVGreg我该怎么做,? – ilhnctn 2012-03-30 14:03:32