林目前正在對一個通用的應用程序時,使得它非常laggy,而在我的視圖控制器我有以下XIB之一:iPad應用程序 - 的CALayer旋轉
View
-ImageView
-TableView
-ImageView
-View (called tblviewContainer in the following snippet of code)
以我viewDidLoad方法我已製成的層我將放在我的視圖(tblviewcontainer)上,以便屏幕的頂部和底部有一些漸變。
[tblViewContainer addSubview:self.tableView];
[tblViewContainer sendSubviewToBack:self.tableView];
if (!maskLayer)
{
maskLayer = [CAGradientLayer layer];
UIColor* outerColorSetup = [UIColor colorWithWhite:1.0 alpha:0.0];
UIColor* innerColorSetup = [UIColor colorWithWhite:1.0 alpha:1.0];
CGColorRef outerColor = outerColorSetup.CGColor;
CGColorRef innerColor = innerColorSetup.CGColor;
maskLayer.colors = [NSArray arrayWithObjects:
(__bridge id)outerColor,
(__bridge id)innerColor,
(__bridge id)innerColor,
(__bridge id)outerColor, nil];
maskLayer.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.01],
[NSNumber numberWithFloat:0.04],
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1.0], nil];
maskLayer.bounds = CGRectMake(0, 0,
self.tableView.frame.size.width,
self.tableView.frame.size.height);
maskLayer.anchorPoint = CGPointZero;
tblViewContainer.layer.mask = maskLayer;
}
在我的應用程序,可以旋轉,當我做到這一點與該層上,這是非常慢/ laggy當我轉動(僅在iPad 3!)。
當我轉動i執行以下操作:(從縱向狀態>橫向)
-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
_landscape = [[ipad_VideoListViewController_Landscape alloc] initWithNibName:@"ipad_VideoListViewController_Landscape" bundle:nil];
_landscape.scroolViewContentOffset = scroolViewContentOffset;
[self.view.layer setRasterizationScale:[UIScreen mainScreen].scale];
self.view.layer.shouldRasterize = YES;
NSMutableArray *viewCons = [[[self navigationController]viewControllers] mutableCopy];
[viewCons removeLastObject];
[viewCons addObject:_landscape];
[[self navigationController]setViewControllers:viewCons animated:NO];
}
}
最糟糕的是它完美的作品在ipad 2的與該層的活性,但ipad的3不能似乎來處理它。它甚至似乎是我在動畫上做的ipad 2(它的工作),不能在ipad 3上處理。我做了我自己的tableview標題單元格/ tableview單元格,並且他們也滯後,如果我在ipad 3上使用它們。
任何幫助,將不勝感激!
添加了以下兩行:(要旋轉) [self.view.layer setRasterizationScale:[UIScreen mainScreen] .scale]; self.view.layer.shouldRasterize = YES; 而下面的行應該去掉: self.view.layer.shouldRasterize = NO; 它幫助很少,所以它仍然不順利。 – Lasse