【问题标题】:willAnimateRotationToInterfaceOrientation not being called in one subview while another is visible and rotatedwillAnimateRotationToInterfaceOrientation 未在一个子视图中调用,而另一个子视图可见并已旋转
【发布时间】:2010-10-24 18:52:59
【问题描述】:

我在 UITabBarController 中有 3 个子视图。第一个选项卡的视图具有在调用 willAnimateRotationToInterfaceOrientation 时手动移动的对象。但是,如果另一个选项卡的视图在旋转时可见,则将永远不会调用 willAnimateRotationToInterfaceOrientation,并且如果我返回第一个选项卡,则第一个选项卡视图上的项目不在正确的位置。

当另一个视图可见时,如何在一个视图中手动移动对象?

【问题讨论】:

    标签: iphone xcode ios ios4 uitabbarcontroller


    【解决方案1】:

    我解决了。我所做的是创建一个从 ViewWillAppear 调用的方法,它获取当前方向并更改屏幕上的对象位置。

    希望这对某人有所帮助。

    - (void)manuallyMoveViewObjects{
    
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    
    if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
        CGRect buttonFrame = CGRectMake(125.0, 223.0, 70.0, 50.0);
    
        self.button.frame = buttonFrame;
    }
    
    else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
        CGRect gbuttonFrame = CGRectMake(205.0, 131.0, 70.0, 50.0);
        self.button.frame = buttonFrame;
    
    }
    

    }

    【讨论】:

    • 它不会让我。说我做不到。
    猜你喜欢
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多