I have trouble with method for animation
I've created my own CalloutBubble for GoogleMap
@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 sizeToFit];
titleLabel.minX = 0;
[titleLabel.layer removeAllAnimations];
if (titleLabel.width > titleView.width)
[self runningLabel];
}
- (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;
[self runningLabel];
}];
}
@end
In my viewController I create property
@implementation MapVC {
CalloutView *calloutView;
}
And then if I try create calloutView in any method all work fine with animation, but if I return view in Google map method
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
{
if (!calloutView)
calloutView = [[CalloutView alloc] initWithFrame:CGRectMake(0, 0, 265, 45.5)];
calloutView.marker = (MapMarker *)marker;
return calloutView;
}
My animation run immediately in calloutView, and completion called immediately too, and call runningLabel
method again, So it is not work like it have to. All frame is good, and timInterval
always more than 4 second. I tried to write static timeinterval like 10.0, but animation again run immediately, and flag finished
in completion block always YES. So it called more than 100 times in one second =(
I create app in iOS 7. I tried to use different options for animation:
UIViewAnimationOptionLayoutSubviews
UIViewAnimationOptionAllowUserInteraction
UIViewAnimationOptionBeginFromCurrentState
UIViewAnimationOptionRepeat
UIViewAnimationOptionAutoreverse
UIViewAnimationOptionOverrideInheritedDuration
UIViewAnimationOptionOverrideInheritedCurve
UIViewAnimationOptionAllowAnimatedContent
UIViewAnimationOptionShowHideTransitionViews
UIViewAnimationOptionOverrideInheritedOptions
but there are no results.
What wrong in this Google map method, why my animation run immediately?
PS minX, width - my categories. minX set frame.origin.X . There are all good with this categories.