开发者

MapView annotation view

i need to change the view of annotation after each 20 second how can i do it

for (int i = 0; i < [_shadowArray count]; i++)
{
    Shadows* shadowObj1;

    shadowObj1 = [_shadowArray objectAtIndex:i];
    CLLocationCoordinate2D location1;   

    location1开发者_Python百科.latitude =  [shadowObj1.position_x floatValue];
    location1.longitude = [shadowObj1.position_y floatValue];   

    annotaionObj = [[AnnotationDelegate alloc] initWithCoordinate:location1 name:@"" sub:@"Catch me! "];
    [_annotationArray addObject:annotaionObj];
    [_mapView     addAnnotation:annotaionObj];

}


You could use the timer,which will repeat after each 20 second ..

NSTimer* m_Timer;
m_Timer =  [NSTimer scheduledTimerWithTimeInterval:2.0
        target:self
        selector:@selector(MyMethod)
        userInfo:nil
        repeats:YES];

if you don't require timer any more ,you first need to invalidate it then assign a nil value

[m_Timer invalidate];
 m_Timer = nil; 

So your file should all these things like.

   -(void) MyMethod
    {
      [self viewAnotation];
    }

-(void) viewAnotation
{

   for (int i = 0; i < [_shadowArray count]; i++)
   {
    Shadows* shadowObj1;

    shadowObj1 = [_shadowArray objectAtIndex:i];
    CLLocationCoordinate2D location1;   

    location1.latitude =  [shadowObj1.position_x floatValue];
    location1.longitude = [shadowObj1.position_y floatValue];   

    annotaionObj = [[AnnotationDelegate alloc] initWithCoordinate:location1 name:@"" sub:@"Catch me! "];
    [_annotationArray addObject:annotaionObj];
    [_mapView     addAnnotation:annotaionObj];

   }

}

To know more for NSTimer plz read the below SO post.

How do I use NSTimer?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜