Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Objective c 错误:请求成员';地点';在非结构或联盟中_Objective C_Xcode - Fatal编程技术网

Objective c 错误:请求成员';地点';在非结构或联盟中

Objective c 错误:请求成员';地点';在非结构或联盟中,objective-c,xcode,Objective C,Xcode,我正在创建一个应用程序,当你触摸一个丘疹时,它会移动到另一个位置。这是我写的代码: pimple.location = (320, 64); (我为粉刺创建了一个IBOutlet并将其连接起来) 我得到以下错误: 在非结构或联合中请求成员“位置” 这是我的.m代码: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *myTouch = [touches anyObject];

我正在创建一个应用程序,当你触摸一个丘疹时,它会移动到另一个位置。这是我写的代码:

pimple.location = (320, 64); 
(我为粉刺创建了一个IBOutlet并将其连接起来)

我得到以下错误:

在非结构或联合中请求成员“位置”

这是我的.m代码:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *myTouch = [touches anyObject];

    CGPoint point = [myTouch locationInView:pimple];
    if ( CGRectContainsPoint(pimple.bounds, point) ) {
        [self checkcollision];
    }


}





-(void)checkcollision {

    label.text += 1;    
    pimple.hidden = YES;
    pimple.location = (320, 64);   //the error
    sad.hidden = NO;

    NSURL* popURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"pop" ofType:@"mp3"]];
    AudioServicesCreateSystemSoundID((CFURLRef) popURL, &popID);

    AudioServicesPlaySystemSound(popID);
}
location属性(可能)的类型为
CGPoint
(一个结构),您不能只通过提供两个数字来指定一个点值。您通常会使用helper函数
CGPointMake
来分配它:

pimple.location = CGPointMake(320, 64);
或:


假设
pimple
UIImageView
对象(基于),您可能希望使用
center
属性更改其位置

pimple.center = CGPointMake(320, 64);


什么是位置?它是什么类型的数据类型?
pimple.center = CGPointMake(320, 64);
pimple.center = (CGPoint){320, 64};