我正在製作一個使用GameKit來報告成就的通用應用程序。在iPhone上運行時,此功能正常運行 - 全屏模式的Game Center視圖控制器向上滑動,並要求我在應用啓動時登錄。iPad上的GameCenter登錄控制器問題
但是,當我在iPad上運行此應用程序時,GC視圖控制器的窗口化iPad版本向上滑動,但一旦停止,屏幕會稍微變灰,我無法與模式視圖控制器交互或還要別的嗎。
我已經縮小問題到加入動畫子層窗口的層時,我使用的應用程序窗口的背景,特別是滾動的效果:在最初:
-(void)startGridScroll
{
//Create layer and pattern it with the grid image as a color
UIImage * gridImage = [UIImage imageNamed:@"scrolling_grid.png"];
UIColor * gridPattern = [UIColor colorWithPatternImage:gridImage];
CALayer * gridLayer = [CALayer layer];
[gridLayer setZPosition:-1];
gridLayer.backgroundColor = gridPattern.CGColor;
//Transform the image on its Y-axis
gridLayer.transform = CATransform3DMakeScale(1.0, -1.0, 1.0);
gridLayer.anchorPoint = CGPointMake(0.0,1.0);
CGSize scrollSize = self.window.bounds.size;
//Make the layer's frame twice the width of the image
gridLayer.frame = CGRectMake(0.0, 0.0, gridImage.size.width + scrollSize.width, scrollSize.height);
//*******This is the line causing the issue******
[self.window.layer addSublayer:gridLayer];
//Define start position and end coordinates for grid image
CGPoint start = CGPointZero;
CGPoint end = CGPointMake(-gridImage.size.width, 0);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.fromValue = [NSValue valueWithCGPoint:start];
animation.toValue = [NSValue valueWithCGPoint:end];
animation.repeatCount = HUGE_VALF;
//Set animation duration and begin
animation.duration = 7.0;
[gridLayer addAnimation:animation forKey:@"position"];
}
我兩次調用此方法application: didFinishLaunchingWithOptions
方法,以及applicationDidBecomeActive
方法。消除一個或另一個呼叫不起作用。如果我對它們都發表評論,Game Center登錄視圖控制器就會滑動並正常工作。
我假設有某種圖層相關的問題正在進行。有小費嗎?