0

アプリケーションに画像のアニメーションセットを実装しようとしています。

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];
4

2 に答える 2

0

あなたはimageからのメッセージを使用してみることができますUIImageView

 newMarker = 
     [
          [RMMarker alloc] 
              initWithUIImage:[myAnimatedView image] 
              anchorPoint:CGPointMake(0.5, 1.0)
     ];

または、必要なものがを作成することである場合は、次のUIImageViewことを試すことができます。

 UIImageView *newMakerImageView = 
     [[UIImageView alloc] initWithImage:
        [
          [RMMarker alloc] 
              initWithUIImage:yourImageHere
              anchorPoint:CGPointMake(0.5, 1.0)
        ]
     ];
于 2010-12-23T11:33:33.080 に答える
0
UIImageView *myAnimatedView = [UIImageView alloc] 

それは単なるコピー/貼り付けエラーかもしれませんが、init を忘れています。

UIImageView *myAnimatedView = [[[UIImageView alloc] initWithFrame:[self bounds]] autorelease]
于 2011-07-08T10:38:58.660 に答える