2010-10-20 151 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文件中的解決方案。然後,我通過一個委託訪問它們。謝謝。