2010-10-20 113 views
1

我在写我的动画第一个应用程序,我陷入一些麻烦。我有创造编程方式添加的UIView一定数量的子视图一个视图控制器。iPhone多子视图动画

现在,当我接触的这些意见,我想将它移到一个方向(上,右,下,左),但前提是在这个方向没有另一种观点认为一个。 这件事是:我怎么能问到的ViewController,如果有一个方向另一种观点?我想:

// In the view controller: 
+ (id)sharedInstance { 
    static id master = nil; 

    @synchronized(self) 
    { 
     if (master == nil) 
     master = [self new]; 
    } 

    return master; 
} 

...

// In the UIView subclass 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    [[MyViewController sharedInstance] touchesEnded:touches withEvent:event launchedBy:numero.text]; 
} 

...

// Finally the method 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event launchedBy:(NSString *)launcher 
{ 
    CGPoint coord = [[cells objectAtIndex:[launcher intValue]] coordinate]; 

    [NumberView beginAnimations:@"MoveAndStrech" context:nil]; 
    [NumberView setAnimationDuration:1]; 
    [NumberView setAnimationBeginsFromCurrentState:YES]; 

    if([touches count] == 1) { 
     if (![map objectForKey:[NSString stringWithFormat:@"%d+%d",coord.x+64,coord.y]]) { 
      NSNumber *isAvailable = [NSNumber numberWithBool:NO]; 
      [map setValue:isAvailable forKey:[NSString stringWithFormat:@"%d+%d",coord.x,coord.y]]; 
      NSLog(@"Dati: %@ all'indice: %d",[cells objectAtIndex:[launcher intValue]-1], [launcher intValue]-1); 
      [[cells objectAtIndex:[launcher intValue]] setCenter:CGPointMake((coord.x+64)/2, coord.y)]/* = CGPointMake((coord.x+64)/2, coord.y)*/; 
      isAvailable = [NSNumber numberWithBool:YES]; 
      [map setValue:isAvailable forKey:[NSString stringWithFormat:@"%d+%d",coord.x+64,coord.y]]; 
     } 
    } 
    [NumberView commitAnimations]; 
} 

不过的NSLog(@“DATI ...给(空) 我应该怎么办。这个?

+1

凡'cells'设置? – deanWombourne 2010-10-20 16:42:44

回答

0

我发现把细胞和地图中的AppDelegate文件中的解决方案。然后,我通过一个委托访问它们。谢谢。