UIViewController
调整大小后如何刷新视图?我需要一种类似于reloadData
in的方法UITableViewController
。
是否有其他可能性来调整视图的大小UIViewController
而不重新加载?
我的代码是:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
orientation = toInterfaceOrientation;
if(orientation==3 || orientation==4)
{
heightBoxDimension1 = [GlobalData sharedGlobalData].heightLandscape;
widthBoxDimension1 = [GlobalData sharedGlobalData].widthLandscapeBig;
widthBoxDimension2 = [GlobalData sharedGlobalData].widthLandscapeSmall;
}
else
{
heightBoxDimension1 = [GlobalData sharedGlobalData].heightPortrait;
widthBoxDimension1 = [GlobalData sharedGlobalData].widthPortraitBig;
widthBoxDimension2 = [GlobalData sharedGlobalData].widthPortraitSmall;
}
for(UIView* view in self.view.subviews)
{
NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
if(view.frame.size.width >400)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, widthBoxDimension1, heightBoxDimension1)];
NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, widthBoxDimension2, heightBoxDimension1)];
NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
}
}
[self.view setNeedsDisplay];
}
我有一类全局变量,在其中放置视图的静态尺寸,我有两种视图,高度相同但宽度不同。当打开模拟器进入此方法但更改视图框架后,不要重新加载这些视图...
控制台的输出是:
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 8 752 318
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 8 752 446
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 334 372 318
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 334 372 446
做好重新框架,但不要重新加载。