2012-09-07 6 views
1

임은 현재 보편적 인 응용 프로그램 작업을 회전시킬 때의 CALayer은 매우 랙이 만들고, 나는 다음과 같은 XIB가 내보기 컨트롤러 중 하나에 : 내있는 viewDidLoad 방법에아이 패드 응용 프로그램 -

View 
-ImageView 
-TableView 
-ImageView 
-View (called tblviewContainer in the following snippet of code) 

을 나는 계층을 만들었습니다 화면의 상단과 하단이 그래디언트가되도록 내보기 (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; 

} 

이 회전 가능하며, 내가의 층으로 그렇게 할 때 회전 할 때, 그것은 랙이/매우 느립니다 (만 아이 패드 3에!).

나는 다음과 같이 회전 할 때 : (portrait-에서> 풍경)

-(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]; 
    } 
} 

최악의 일부가 활성 레이어와 아이 패드 2에 완벽하게 작동하지만, 아이 패드 3 캔트 그것을 처리하는 것. 심지어 ipad 2 (작동)에서 애니메이션으로하는 일은 ipad에서 처리 할 수 ​​없다. 나는 자신의 tableview 헤더 셀/tableview 셀을 만들었고 ipad 3에서 사용하면 지연됩니다.

도움이 될만한 도움이 될 것입니다!

+0

다음 두 줄을 추가했습니다. (to willrotate) [self.view.layer setRasterizationScale : [UIScreen mainScreen] .scale]; self.view.layer.shouldRasterize = YES; 그리고 다음 줄을 참고하십시오 : self.view.layer.shouldRasterize = NO; 매우 도움이 되었기 때문에 여전히 원활하지 않았습니다. – Lasse

답변

1

일부 투명 이미지가 추가되어 원활하게 실행됩니다.

아직도 작동하지 않는 이유를 알고있는 사람이 누구인지 알고 싶습니다.

마감 시간이 있기 때문에이 해결책을 찾아야했습니다. :).

의견을 보내 주셔서 감사합니다. Michael!

0

은 willRotateToInterfaceOrientation에 rasterizing을보십시오 : 귀하의 didRotateToInterfaceOrientation에

self.view.layer.shouldRasterize = YES; 

: 그리고

self.view.layer.shouldRasterize = NO; 

은 또한 당신의 층이 가능한 곳 불투명 있는지 확인하십시오.

+0

나는 나중에 시험해보고 도움이되는지 아닌지 게시 할 예정입니다. – Lasse

+0

그것은 작동하지 않았다. 이전처럼 부드럽지 않은 회전. 그리고 self.view.layer 대신 tblviewcontainer.layer가 아닌가요? 왜냐하면 거기에 레이어가 추가되기 때문입니다. 결코 적게, 나는 양쪽을 시험해 보았다. 그리고 그들 중의 누구도 차이를 만들지 않았다. (그리고 나는 또한 내 조경 컨트롤러에서 이것에 대해서도 짐작할 만하다. 나는 어느 것을 했는가! :)) – Lasse