ios 7 UIView animateWithDuration : .。立即运行
<p><p>动画方法有问题</p>
<p>我已经为 GoogleMap 创建了自己的 CalloutBubble</p>
<pre><code>@interface CalloutView : UIView
@property (nonatomic) MapMarker *marker;
@end
@implementation {
UIView *titleView;
UILabel *titleLabel, *addressLabel;
}
//another init methods aren't shown
- (void)setMarker:(MapMarker *)marker
{
_marker = marker;
titleLabel.text = marker.university.name;
addressLabel.text = marker.university.address;
;
titleLabel.minX = 0;
;
if (titleLabel.width > titleView.width)
;
}
- (void)runningLabel
{
CGFloat timeInterval = titleLabel.width / 70;
[UIView animateWithDuration:timeInterval delay:1.0 options:UIViewAnimationOptionOverrideInheritedDuration | UIViewAnimationOptionRepeat animations:^{
titleLabel.minX = -titleLabel.width;
} completion:^(BOOL finished) {
titleLabel.minX = titleView.width;
;
}];
}
@end
</code></pre>
<p>在我的 viewController 我创建属性</p>
<pre><code>@implementation MapVC {
CalloutView *calloutView;
}
</code></pre>
<p>然后,如果我尝试在任何方法中创建 calloutView,所有动画都可以正常工作,但如果我在 Googlemap 方法中返回 View </p>
<pre><code>- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
{
if (!calloutView)
calloutView = [ initWithFrame:CGRectMake(0, 0, 265, 45.5)];
calloutView.marker = (MapMarker *)marker;
return calloutView;
}
</code></pre>
<p>我的动画在 calloutView 中立即运行,完成也立即调用,并再次调用 <code>runningLabel</code> 方法,所以它不是必须的。所有帧都很好,并且 <code>timInterval</code> 总是超过 4 秒。我尝试编写像 10.0 这样的静态时间间隔,但动画再次立即运行,并且在完成 block 中标记 <code>finished</code> 始终是。所以它在一秒钟内调用了100多次=(</p>
<p>我在 iOS 7 中创建应用程序。我尝试使用不同的动画选项:</p>
<pre><code>UIViewAnimationOptionLayoutSubviews
UIViewAnimationOptionAllowUserInteraction
UIViewAnimationOptionBeginFromCurrentState
UIViewAnimationOptionRepeat
UIViewAnimationOptionAutoreverse
UIViewAnimationOptionOverrideInheritedDuration
UIViewAnimationOptionOverrideInheritedCurve
UIViewAnimationOptionAllowAnimatedContent
UIViewAnimationOptionShowHideTransitionViews
UIViewAnimationOptionOverrideInheritedOptions
</code></pre>
<p>但没有结果。</p>
<p>这个谷歌地图方法有什么问题,为什么我的动画立即运行? </p>
<p>PS minX,宽度 - 我的类别。 minX 设置 frame.origin.X 。这个类别都有不错的。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>移除 UIViewAnimationOptionRepeat 选项或注释完成 Block minX 设置:</p>
<pre><code>- (void)runningLabel
{
CGFloat timeInterval = titleLabel.width / 70;
[UIView animateWithDuration:timeInterval delay:1.0 options:UIViewAnimationOptionOverrideInheritedDuration | UIViewAnimationOptionRepeat animations:^{
titleLabel.minX = -titleLabel.width;
} completion:^(BOOL finished) {
//titleLabel.minX = titleView.width; //this is the problem, you should not set minX again whileUIViewAnimationOptionRepeat also is animation option
;
}];
}
</code></pre></p>
<p style="font-size: 20px;">关于ios 7 UIView animateWithDuration : .。立即运行,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21846898/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21846898/
</a>
</p>
页:
[1]