2011-04-20 54 views
-1

我在图像视图中创建了一个正方形。它们中的每一个都是ArrayObject。 如果我触摸左上角,我希望我的图像正方形的中间位于左下角。同时移动4个NSMutableArray对象

我该怎么做?

+1

你会得到更多(更好)的反应,如果你的问题标题更加具体和您发布的更多细节到底是什么您正在尝试执行以及您目前尝试的操作,包括相关示例代码。 – XJones 2011-04-20 17:55:14

+0

我知道,我在网吧的事情,我不得不输入非常快......我知道这个问题会得到一个减号:) – DailyDoggy 2011-04-22 09:24:33

回答

1

我不确定你的问题是什么。我假设如下:

  1. 您的网格是与存储在gridWidth

  2. 对象网格尺寸的正方形存储在gridArray从顶部下令从左上到右下

  3. 当在网格中的对象的左上角中检测到轻击时,userTappedObject:被称为

  4. 您有一个名为`layoutGrid'的函数,它是沃尔玛KS阵列,并设置每个对象的框架

例子:

- (void)userTappedObject:(id)tappedObject 
{ 
    NSUInteger indexOfBottomLeft = gridWidth * (gridWidth - 1); 

    // to exchange the tapped object with the object in the bottom left corner 
    NSUInteger indexOfTappedObject = [myMutableArray indexOfObject:tappedObject]; 
    [gridArray exchangeObjectAtIndex:indexOfTappedObject withObjectAtIndex:indexOfBottomLeft]; 

    // to move the tapped object to the bottom left corner, collapsing objects to the left 
    // from the bottom left corner to make room 
    [gridArray removeObject:tappedObject]; 
    [gridArray insertObject:tappedObject atIndex:indexOfBottomLeft]; 

    // layout the grid (this could animate changes if desired) 
    [self layoutGrid]; 
} 
+0

谢谢,但我认为这不是什么即时通讯寻找...对不起。无论如何,伊尔给你那个+:D – DailyDoggy 2011-04-22 09:26:32