IPhone-没有获得界面定向

IPhone-没有获得界面定向,iphone,Iphone,当我改变IPhone的方向时,我正试图为UIButton设置另一个位置,我想在BOOLshouldAutorotateToInterfaceOrientation内实现它:UIInterfaceOrientationinterfaceOrientation。 这是正确的实现方式还是我的代码中有错误?它不会打印这些日志 代码: } 问候 shouldAutorotateToInterfaceOrientation仅指定UIViewController支持哪些旋转-仅此而已 你可以考虑修改WiRot

当我改变IPhone的方向时,我正试图为UIButton设置另一个位置,我想在BOOLshouldAutorotateToInterfaceOrientation内实现它:UIInterfaceOrientationinterfaceOrientation。 这是正确的实现方式还是我的代码中有错误?它不会打印这些日志

代码:

}


问候

shouldAutorotateToInterfaceOrientation仅指定UIViewController支持哪些旋转-仅此而已

你可以考虑修改WiRotoTutoToFrasePosi定位,这就在旋转开始之前——隐藏背景视图或其他对象,例如:


然后,重写didRotateFromInterfaceOrientation,这是在旋转刚刚完成后调用的-我认为这一个对您的setFrame:code最重要。

您的代码也应该可以工作,但请尝试放置以下代码。变化是从UIDeviceOrientation到UIInterfaceOrientation


我不明白,adButton setFrame是否正常工作,并且这个viewcontroller是root,或者您有另一个。难道根控制器不应该自动旋转指针面方向对任何方向都返回否吗?

Mate,我刚刚尝试了willRotateToInterfaceOrientation和didRotateFromInterfaceOrientation。两者都不起作用。还有其他方法吗?你有没有把NSLogs放在里面或者类似的?他们没有被击中吗?在“摘要”选项卡中,您支持哪些方向?如果在shouldAutorotateToInterfaceOrientation:方法中注释掉代码并替换它,使其与摘要中列出的方向匹配,然后重试。最后,这个当前视图控制器是否继承了其他可能覆盖其支持的方向的对象?我在这些方法中放入了一些nslog,但没有抛出任何一个。我想他们没有被叫来。我也检查了遗产,那里没有什么问题。太好了,这是我的错误!谢谢!
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if ((interfaceOrientation == UIDeviceOrientationLandscapeLeft) ||
    (interfaceOrientation == UIDeviceOrientationLandscapeRight))
{
    NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: left or right");
    [adButton setFrame:CGRectMake(100, 700, 768, 90)];
}
if ((interfaceOrientation == UIDeviceOrientationPortrait) ||
    (interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
{
    NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: Portrait or UpsideDown portrait");
    [adButton setFrame:CGRectMake(0, 0, 768, 90)];
}
return YES;
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
        NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: left or right");
        [adButton setFrame:CGRectMake(100, 700, 768, 90)];
    }
    if ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
    {
        NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: Portrait or UpsideDown portrait");
        [adButton setFrame:CGRectMake(0, 0, 768, 90)];
    }
    return YES;
}