アプリケーションに画像のアニメーションセットを実装しようとしています。
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 0.25; // seconds
myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[myAnimatedView release];
わかりましたが、問題は、API関数を使用して地図上にマーカーを配置していることです。
その関数は次のとおりです。
RMMarker *newMarker;
UIImage *blueMarkerImage = [UIImage imageNamed:@"marker.png"];
newMarker = [[RMMarker alloc] initWithUIImage:blueMarkerImage anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:position];
[newMarker release];
問題は、「initWithUIImage:」がUIImageでのみ機能し、UIImageViewでは機能しないことです。
だから、どうすればそれを解決できますか?
更新:機能していない私の新しいコード:
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"marker0.png"],
[UIImage imageNamed:@"marker1.png"],
[UIImage imageNamed:@"marker2.png"],
[UIImage imageNamed:@"marker3.png"],
[UIImage imageNamed:@"marker4.png"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 10; // seconds
myAnimatedView.animationRepeatCount = 1; // 0 = loops forever
[myAnimatedView startAnimating];
RMMarker *newMarker = [[RMMarker alloc] initWithUIImage:[myAnimatedView image] anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:markerPosition];