Im travaille actuellement sur une application universelle, et dans un de mes vue contrôleurs j'ai les xib suivants:app iPad - CALayer rend très laggy lors de la rotation
View
-ImageView
-TableView
-ImageView
-View (called tblviewContainer in the following snippet of code)
Dans ma méthode viewDidLoad j'ai fait une couche que je vais mettre sur ma vue (tblviewcontainer) de sorte que certains du haut et le bas de l'écran est dégradé.
[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;
}
Dans mon application, il est possible de faire tourner, et quand je le fais avec la couche sur, il est très lent/lag quand je rotate (uniquement sur iPad 3!).
Quand je tourne, je fais ce qui suit: (de Portrait-> paysage)
-(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];
}
}
Le pire est-il fonctionne parfaitement sur l'iPad 2 avec la couche active, mais ipad 3 cant semblent manipuler. Il semble même que les choses que je fais avec l'animation sur ipad 2 (qui fonctionne), ne peut pas être manipuler sur l'ipad 3. Par exemple. J'ai fait mes propres cellules d'en-tête de tableview/cellules de tableview, et elles traînent également si je les emploie sur l'IPAD 3.
N'importe quelle aide serait appréciée!
Ajout des deux lignes suivantes: (to willrotate) [self.view.layer setRasterizationScale: [UIScreen mainScreen] .scale]; self.view.layer.shouldRasterize = YES; Et la ligne suivante à shouldautorotate: self.view.layer.shouldRasterize = NO; Il a aidé très peu, donc ce n'est toujours pas lisse. – Lasse