我正在尝试在我的应用程序上实现一组动画图像。
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];