C# 在iOS7中如何防止视图在屏幕外显示?

C# 在iOS7中如何防止视图在屏幕外显示?,c#,iphone,ios7,screen-orientation,screen-positioning,C#,Iphone,Ios7,Screen Orientation,Screen Positioning,我们正在更新我们的应用程序以与iOS7配合使用,并且在方向和视图放置方面遇到了很多问题 我们使用的视图显示从 类别->位置->位置信息 位置和位置信息视图上有一个返回按钮,可转到上一屏幕。然而,只要按下后退按钮,视图就会在屏幕外的某个位置居中。我之所以知道这一点,是因为在iPhone上运行时,我使用了revealapp应用程序(revealapp.com)来查看视图的位置 当视图在屏幕上正确定位时,其容器视图中心设置为(X:160,Y:240) 但当我按下后退按钮时,视图位于相对的角落,容器视图

我们正在更新我们的应用程序以与iOS7配合使用,并且在方向和视图放置方面遇到了很多问题

我们使用的视图显示从

类别->位置->位置信息

位置和位置信息视图上有一个返回按钮,可转到上一屏幕。然而,只要按下后退按钮,视图就会在屏幕外的某个位置居中。我之所以知道这一点,是因为在iPhone上运行时,我使用了revealapp应用程序(revealapp.com)来查看视图的位置

当视图在屏幕上正确定位时,其容器视图中心设置为(X:160,Y:240)

但当我按下后退按钮时,视图位于相对的角落,容器视图坐标现在设置为(X:160,Y:720)

你知道这是什么原因吗

我们的UI需要在横向模式下工作,在iOS7升级时,我们在保持这种方向方面遇到了各种各样的问题

任何帮助或线索都将不胜感激

我包括了控制方向的脚本

/*
 *  Portable.cpp
 *  Unity-iPhone
 *
 *  Created by macmini on 8/25/10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */
#include "UnityAppController.h"
#include "Portable.h"
#include "RootViewController.h"
#include "DBConnection.h"
#import "DeviceID.h"
#ifdef USE_FRONT_END_CTRLR
#import "FBFrontendController.h"
#endif

extern UIWindow *uiWindow;
void UnityPause(bool pause);
RootViewController *controller;
bool unityPaused = false;
bool inDesiredOrientation = false;

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    UIInterfaceOrientation o = self.interfaceOrientation;
    UIInterfaceOrientation ob = [UIDevice currentDevice].orientation;

    if (ob == UIDeviceOrientationLandscapeRight && o == UIDeviceOrientationLandscapeRight)
        inDesiredOrientation = true;
    if (ob == UIDeviceOrientationLandscapeRight)
        return YES;
    if (inDesiredOrientation)
        return NO;
    if (o == UIDeviceOrientationLandscapeRight)
        return YES;
    return NO;
 }

@end

extern "C" void PauseUnity() {
    unityPaused = true;
    UnityPause(true);
}

extern "C" void ResumeUnity() {
    unityPaused = false;
    UnityPause(false);
}

bool UnityPaused() {
    return unityPaused;
}

extern "C" void ShowModalUI()
{
    UnityPause(true);
    if (uiWindow==nil) 
    {

        UIScreen *MainScreen=[UIScreen mainScreen];
        UIScreenMode *ScreenMode=[MainScreen currentMode];
        CGSize sSize=[ScreenMode size];



        NSString *deviceType = [UIDevice currentDevice].model;
        NSString *platformStr = [[DeviceID sharedDeviceID] platformString];
        CGRect windowFrame;
        if([deviceType isEqualToString:@"iPhone"]) {
            windowFrame = CGRectMake(0,0,sSize.width, sSize.height);
        } else {
            windowFrame = CGRectMake(0,0,sSize.height, sSize.width);
        }

        uiWindow = [[[UIWindow alloc] initWithFrame: windowFrame] retain];

        [uiWindow makeKeyAndVisible];

        controller = [RootViewController sharedRootView];

        //controller.delegate = mainController;

        UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:controller];
        //[controller release];

        [[naviController navigationBar] setBarStyle:UIBarStyleBlack];

        naviController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        //[mainController presentModalViewController:navController animated:YES];


        [DBConnection openConnection];
        [uiWindow addSubview:naviController.view];


        //[naviController release];
        [controller retain];
        //[naviController retain];

        uiWindow.rootViewController = naviController;
    }
    else {
        [uiWindow setHidden:NO];
        [uiWindow makeKeyAndVisible];

    }


}


extern "C" void ShowStore(const char *storeName) {
#if USE_FRONT_END_CTRLR==1
    if (strncmp(storeName, "Day ", 4) == 0) {
        char *s = (char *) malloc(strlen(storeName) + 1);
        strcpy(s, storeName);
        NSString *storeNameStr = [[NSString stringWithCString:s encoding:NSUTF8StringEncoding] retain];
        [[FBFrontendController sharedFrontEndController] ShowDetailViewOf:storeNameStr];
    } else
#endif
    {
        ShowModalUI();
        UnityPause(true);
        [uiWindow setHidden:NO];
        [uiWindow makeKeyAndVisible];
        char *s = (char *) malloc(strlen(storeName) + 1);
        strcpy(s, storeName);
        [controller ShowStoreByName:s];
    }


    //[[FBFrontendController sharedFrontEndController] popupDetail];
    return;
}

//#ifndef USE_FRONT_END_CTRLR
//extern "C" void _showHTMLGuide() {
//}
//#endif

extern "C" void ShowStore_(const char *storeName) {
    ShowStore(storeName);
}

显示一些代码将使人们更容易帮助您。您是在摆弄视图的框架,还是可能有一些自动布局约束错误?我添加了我认为可以控制方向的代码。我希望这会有帮助。卡梅隆,我会调查一下汽车的布局。