移动数组中的对象

时间:2015-09-17 14:37:51

标签: ios objective-c objective-c-2.0

如何移动此数组中的对象?尝试了一切。我无法选择单个对象。

self.images = [NSMutableArray array];
NSFileManager* manager = [NSFileManager new];
NSBundle* bundle = [NSBundle mainBundle];
NSDirectoryEnumerator* enumerator = [manager enumeratorAtPath:[bundle bundlePath]];

for (NSString* name in enumerator) {
    if ([name hasSuffix:@"PawnWhite.png"]) {
        for (int i = 0; i <= 7; i++) {
            UIImage* image = [UIImage imageNamed:name];
            [self.images addObject:image];
        }
    }
}

for (int i = 0; i < self.images.count; i++) {
    CGPoint myPoint = CGPointMake(75.f, 0);

    self.view = [[UIView alloc] initWithFrame:CGRectMake(84.f + myPoint.x * i, 870.f, 75.f, 75.f)];

    self.imagesView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    self.imagesView.image = [self.images objectAtIndex:i];

    [self.view addSubview:self.imagesView];
    [valueView addSubview:self.view];
}

我在阵列中有图片,映射在主视图上。我需要改变她改变位置的任何一个。

1 个答案:

答案 0 :(得分:2)

如果要在数组中移动对象 - 只需从一个位置移除一个项目,然后将其添加到另一个位置,如下所示:

${GIT_BRANCH}-${GIT_REVISION,length=8}-${ENV,var="BUILD_TYPE"}
相关问题