Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 带UIImageView数组的center.x和center.y?_Iphone_Objective C_Ios - Fatal编程技术网

Iphone 带UIImageView数组的center.x和center.y?

Iphone 带UIImageView数组的center.x和center.y?,iphone,objective-c,ios,Iphone,Objective C,Ios,因此,我创建了一个UIImageView的NSMutableArray,如下所示: NSMutableArray* imageViewArray = [[NSMutableArray alloc] init]; for(int i = 0; i < 15; i++){ UIImageView* imageView = [self animationInit:imageArray xPos:0 yPos:480 wFrame:32

因此,我创建了一个
UIImageView
NSMutableArray
,如下所示:

NSMutableArray* imageViewArray = [[NSMutableArray alloc] init];
for(int i = 0; i < 15; i++){
    UIImageView* imageView = [self animationInit:imageArray xPos:0 yPos:480 wFrame:32
                                                      hFrame:32 duration:0.5 repeat:0];
    [imageViewArray addObject:imageView];
    [imageView release];
    imageView = nil;
    [self.view addSubview:[imageViewArray objectAtIndex:i]];
}
[imageViewArray objectAtIndex:Index] setCenter:CGPointMake(x, y)];
我可以使用以下方法设置阵列中每个UIImageView的中心:

NSMutableArray* imageViewArray = [[NSMutableArray alloc] init];
for(int i = 0; i < 15; i++){
    UIImageView* imageView = [self animationInit:imageArray xPos:0 yPos:480 wFrame:32
                                                      hFrame:32 duration:0.5 repeat:0];
    [imageViewArray addObject:imageView];
    [imageView release];
    imageView = nil;
    [self.view addSubview:[imageViewArray objectAtIndex:i]];
}
[imageViewArray objectAtIndex:Index] setCenter:CGPointMake(x, y)];
现在,我希望能够像使用普通
UIImageView
一样修改
x
y
点。例如:
UIImageView.center=CGPointMake(UIImageView.center.x+5,UIImageView.center.y+5)

这里的问题是我不知道如何访问
UIImageView
数组中的“UIImageView.center.x/y”。有没有办法像我使用“setCenter:”那样访问“center.x/y”,或者我最好创建一堆
CGPoints
来保存数组中
UIImageViews
x
y

当我尝试
[imageViewArray objectatited:Index].center.x
时,出现以下错误

在非结构或联盟中请求成员“中心”


是否有解决方案或解决方法?

要访问
UIImageView
数组的
x
y
值,必须使用以下选项

[imageViewArray objectAtIndex:Index] center].x
UIImageView.center = CGPointMake(UIImageView.center.x + 5, UIImageView.center.y + 5);
有了这些,我可以使用下面的方法

[imageViewArray objectAtIndex:Index] center].x
UIImageView.center = CGPointMake(UIImageView.center.x + 5, UIImageView.center.y + 5);
像这样:

[[imageViewArray objectAtIndex:Index] setCenter:CGPointMake([imageViewArray objectAtIndex:Index] center].x + 5, [imageViewArray objectAtIndex:Index] center].y + 5)];
再次为我造成的混乱和混乱道歉。我把自己和这个搞混了


(我找到了解决方案,并认为最好将其共享,以防其他人遇到相同的问题。)

您可以在阵列中的图像视图中循环并更改其中心属性。你有什么问题吗?对不起,我想我不太擅长解释我想做的事情是这样的:[[imageViewArray objectAtIndex:Index]setCenter:CGPointMake([imageViewArray objectAtIndex:Index].x+5[imageViewArray objectAtIndex:Index].y+5]);但很明显,这是不可能的方式,我写它。现在这更有意义了吗?你可以这样做吗?你为什么说这不可能?我真不敢相信我没听懂。我只是回答了我自己的问题,没有意识到这一点。我想因为我使用了“设置中心”,所以我需要以相同的方式访问x点和y点。因此,我正在寻找一种类似于[[imageViewArray objectAtIndex:Index]setCenter:]语法的解决方案,我认为这种语法不适合尝试“.”语法。我觉得自己像个傻瓜。不管怎样,感谢您抽出时间查看我的问题并提供您的意见。好的,我错了/对了,但请注意使用[imageViewArray objectAtIndex:Index].center.x的问题是什么。当我尝试以这种方式使用它时,我得到了以下错误:“在非结构或联合中请求成员‘中心’”。这就是为什么我在寻找另一种选择。很抱歉让人困惑,我也将编辑我的原始问题。