Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.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 方向中的UIButton出现问题_Iphone_Objective C_Orientation - Fatal编程技术网

Iphone 方向中的UIButton出现问题

Iphone 方向中的UIButton出现问题,iphone,objective-c,orientation,Iphone,Objective C,Orientation,我有一个按钮,我需要找到它的每个方向在不同的位置。 给你 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (interfaceOrientation== UIInterfaceOrientationPortrait || interfaceOrientation== UIInterfaceOrientationPortraitDown) button.

我有一个按钮,我需要找到它的每个方向在不同的位置。 给你

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation== UIInterfaceOrientationPortrait || interfaceOrientation== UIInterfaceOrientationPortraitDown)
button.frame=CGRectMake(150.0f,150.0f,55.0f,55.0f);
else
button.frame=CGRectMake(100.0f,100.0f,55.0f,55.0f);   
 return YES;
}
当我再次旋转IPad时,按钮转到另一个位置。
例如,在UIInterfaceOrientationPortrait中,按钮不在此处(150.0f、150.0f、55.0f、55.0f) 如何解决此问题?
谢谢您的帮助。

方法中参数的名称是
interface-orientation
,但您正在检查
方向。您应该检查
接口方向

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitDown) {
         button.frame = CGRectMake(150.0f, 150.0f, 55.0f, 55.0f); 
    } 
    else {
         button.frame = CGRectMake(100.0f, 100.0f, 55.0f, 55.0f);
         return YES;
    }
}

您正在检查
UIInterfaceOrientationGraphitation
UIInterfaceOrientationGraphitationDown


但是正确的枚举名称是
UIInterfaceOrientationGraphicalUpsideDown

见:


你说“去另一个地方”是什么意思?UIInterfaceOrientationGraphitalDown根本不存在。还有一个错误粘贴从OP?我放弃了这一点,如果OP连他的代码都不能完整地呈现给我们,那么这就是问题所在吗?你修好了,现在可以用了?还是你只是吃错了?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation== UIInterfaceOrientationPortrait || interfaceOrientation== UIInterfaceOrientationPortraitUpsideDown)
button.frame=CGRectMake(150.0f,150.0f,55.0f,55.0f);
else
button.frame=CGRectMake(100.0f,100.0f,55.0f,55.0f);   
 return YES;
}