NSTimer阻止其他动画 [英] NSTimer blocks other animations
问题描述
说明
我有一个NSTimer
,它每秒更新一次UILabel
.我还有另一个UIImageView
,当按下UIButton
时,它会在屏幕上滑动.
问题
问题在于,当NSTimer
更新UILabel
时,UImageView
的动画停止完成.
问题
请您告诉我如何在不干扰其他动画的情况下更新计时器?
这是
如果要使用自动布局,请通过更改约束而不是更改
I have a The problem is that when the Please can you tell me how can i update the timer without messing with the other animations? This is a common symptom of having auto layout turned on but are probably trying to slide it across the screen by adjusting the Two solutions: Turn off auto layout by opening up your storyboard or NIB, click on the first "document inspector" tab on the rightmost panel, and then uncheck "Use Autolayout". If you want to use autolayout, animate the moving of the control by changing constraints rather than changing
这篇关于NSTimer阻止其他动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!frame
或center
来动画化控件的移动.请参见此处,以获取有关如何创建约束的IBOutlet
然后在animateWithDuration
阻止.参考文献:
Description
NSTimer
that updates an UILabel
every second. I have another UIImageView
that slides in the screen when a UIButton
is pressed.Issue
NSTimer
updates the UILabel
, the animation of the UImageView
stops from completing.Question
frame
or center
. Auto layout is a iOS 6+ feature that controls the location and size of various UIView
elements. Unfortunately, when you have auto layout on, every time you change a label's value, it will reapply the constraints that dictate where the label should be positioned, defeating your attempts to animate it.
frame
or center
. See here for an example of how you can create an IBOutlet
for a constraint and then change that constraint programmatically in an animateWithDuration
block.References: