我试图从上到下制作视图幻灯片.这不是什么大问题,我用CABasicAnimation这个.问题是当我想删除视图时.我用这个动画.
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDelegate:self];
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.layer.position.x, 0 - self.view.bounds.size.height / 2)];
animation.fromValue = [NSValue valueWithCGPoint:self.view.layer.position];
animation.autoreverses = NO;
animation.repeatCount = 0;
animation.duration = 0.25;
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
[self.view.layer addAnimation:animation forKey:@"moveX"];
Run Code Online (Sandbox Code Playgroud)
这完美地激发了视图的动画效果.但是,在动画结束后,我的视图再次出现.所以我添加了这一行:
[self.view removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)
这会移除视图,但没有动画.所以我决定将删除代码添加到此委托:
-(void) animationDidStop:(CAAnimation *) animation finished:(bool) flag
Run Code Online (Sandbox Code Playgroud)
所以现在,动画工作,视图消失,但有时,我可以看到视图出现并消失得更快,就像在动画之后,视图出现,然后animationDidStop调用委托,视图消失,显然这很糟糕.我究竟做错了什么?
我的背景音频几乎一直都很好.屏幕锁定或静音开启.但是当用户在后台运行应用程序并且它接收到呼叫时,即使用户没有应答呼叫,在中断结束后也不会恢复背景音频.
音乐应用程序如果被中断,则会正确恢复背景音频.
我是否遗漏了一些属性,或者我是否需要进行回调或设置后台任务以在中断后继续执行后台音频执行?或者这是我们做不到的事情?
我正在使用导航控制器,我将样式设置为:
navController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Run Code Online (Sandbox Code Playgroud)
但是当我运行我的程序时,导航控制器看起来像是在白色背景之上,而不是我的背景.当我向左或向右推动控制器时,我的所有视图(当前视图)都会移动到顶部,与导航栏的大小完全相同.在那里我可以通过导航控制器栏看到我的背景.有任何想法吗?当我的barStyle设置为不透明时,一切看起来都很好.我在考虑将我的视图框设置为负"y"值,但我认为应该采用更优雅的方式.
我有一个使用加速度计的应用程序.有时,应用程序将在没有加速计数据更新的情况下启动.重新启动应用程序,有时问题仍然存在,有时它不会.甚至更奇怪,有时我可以尝试10次,一切都按预期工作.这是一个错误,或者可能是我遗漏的东西.调试时,加速度计未更新时,永远不会调用此代码:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想使用显示"无限"符号
CGContextSelectFont(context, "HelveticaNeue", textSize, kCGEncodingMacRoman);
CGContextShowTextAtPoint(context, myCenter.x, myCenter.y + textHeight, [sName cStringUsingEncoding:NSMacOSRomanStringEncoding], [sName length]);
Run Code Online (Sandbox Code Playgroud)
它显示为方框或圆形.我发现这个符号是十六进制176和221E十六进制格式.我使用Helvetica作为我的字体,并尝试过其他没有运气的人.这是我正在使用的编码的问题吗?
我CGContextShowText用来显示文本,但是当使用它旋转时CGAffineTransformation,旋转轴位于左侧,而不是绘制文本的中心,我使用的代码是:
CGContextSaveGState(context);
CGContextSelectFont(context, "Helvetica", 20, kCGEncodingMacRoman);
CGContextSetCharacterSpacing (context, 1);
CGContextSetRGBFillColor (context, 0, 0, 0, 1);
CGAffineTransform xform = CGAffineTransformMake(
sin(DegreesToRadians(angle)), cos(DegreesToRadians(angle)),
cos(DegreesToRadians(angle)), -sin(DegreesToRadians(angle)),
0, 0);
CGContextSetTextDrawingMode (context, kCGTextFill);
CGPoint degreeDisplayPoint = CGPointMake(100,100);
CGContextShowTextAtPoint(context, degreeDisplayPoint.x, degreeDisplayPoint.y, [angleStringWithDegree cStringUsingEncoding:NSMacOSRomanStringEncoding], [angleStringWithDegree length]);
CGContextRestoreGState(context);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?