【问题标题】:How to rotate an Info Button with the view?如何使用视图旋转信息按钮?
【发布时间】:2010-02-02 14:08:43
【问题描述】:

我只是想写一个基于视图的应用程序,它只使用横向。

使用此代码:

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;

applicationDidFinishedLaunching 方法中,应用程序以横向启动。

问题是,如果我在 InterfaceBuilder 中创建横向视图,则视图不会以我创建它的方式显示...我需要以纵向模式创建视图并想象它在肖像模式(希望你明白我的意思?) - 我插入已经旋转的图像。 所以,我现在一切正常,但 InfoButton 没有旋转(与其他按钮一样,但其他按钮已经旋转了图像)...

我的错是什么?如何告诉应用程序使用我在横向设计的视图?

非常感谢。

问候

【问题讨论】:

    标签: iphone sdk orientation landscape


    【解决方案1】:

    您可能需要根据方向旋转视图(按钮):

    UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation;
    CGAffineTransform transform;
    switch (orientation) {
        case UIDeviceOrientationPortrait:
            transform = CGAffineTransformIdentity;
            break;
        case UIDeviceOrientationPortraitUpsideDown:
            transform = CGAffineTransformMakeRotation(180*M_PI/180);
            break;
        case UIDeviceOrientationLandscapeLeft:
            transform = CGAffineTransformMakeRotation(90*M_PI/180);
            break;
        case UIDeviceOrientationLandscapeRight:
            transform = CGAffineTransformMakeRotation(-90.0*M_PI/180);
            break;
        default:
            transform = CGAffineTransformIdentity;
            break;
    }
    [[myView layer] setAffineTransform:transform];
    

    【讨论】:

      【解决方案2】:

      您无需在纵向模式下创建视图并想象它在纵向模式下的外观。只需要以所需的模式创建视图,然后将项目设置设置为所需的模式。在左侧视图的Xcode 中,您可以看到Project Navigator 单击项目名称的蓝色图标。现在在中间视图(编辑器视图)上,您可以看到summary 选项卡,在此选项卡上将您需要的模式设置为iPhone Development Orientations

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多