【问题标题】:UIView shows wrong orientationUIView 显示错误的方向
【发布时间】:2011-05-27 19:41:10
【问题描述】:

在模拟器上一切正常,但在真正的 iphone 3g 上存在错误。 我两次调用启动画面。第一次 - 好的,我第二次看到这个错误:http://img413.imageshack.us/i/bugicu.png/

我该如何解决?

@interface iStateGameAppDelegate : NSObject { UIWindow* 窗口; UINavigationController* 导航控制器; } -(无效)showSpalshScreen; -(无效)showSwitchViewController; @property (nonatomic, 保留) IBOutlet UIWindow *window; @property (nonatomic, 保留) IBOutlet UINavigationController *navigationController; @结尾 @implementation iStateGameAppDelegate @synthesize 窗口; @synthesize 导航控制器; - (BOOL) 应用程序:(UIApplication*) 应用程序 didFinishLaunchingWithOptions:(NSDictionary*) 启动选项 { [self showSpalshScreen]; [窗口 makeKeyAndVisible]; 返回是; } -(无效)showSpalshScreen { SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:[NSBundle mainBundle]] autorelease]; [窗口添加子视图:[splashScreen 视图]]; } -(无效)showSwitchViewController { SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:[NSBundle mainBundle]] autorelease]; [窗口添加子视图:[splashScreen 视图]]; } -(无效)dealloc { [导航控制器发布]; [窗口释放]; [超级释放]; } @interface SplashScreen : UIViewController {} @结尾 @implementation 闪屏 // 实现 viewDidLoad 以在加载视图后进行额外的设置,通常来自 nib。 - (void)viewDidLoad { [超级视图DidLoad]; NSTimer *timer = [[NSTimer timerWithTimeInterval:1.0 target:self 选择器:@selector(timerFired:) userInfo:nil repeats:NO] retain]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 返回(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight); } - (void)timerFired:(NSTimer *)timer { [[UIApplication sharedApplication] setStatusBarHidden:FALSE]; iStateGameAppDelegate* app = [UIApplication sharedApplication].delegate; [app showSwitchViewController]; [[自拍] removeFromSuperview]; [定时器无效]; [定时器释放]; 计时器=无; } - (无效)dealloc { [超级释放]; }

【问题讨论】:

    标签: iphone uiview uiviewcontroller


    【解决方案1】:
    1. 确保正确设置视图的委托。
    2. 您可能应该同时检查UIInterfaceOrientationLandscapeRightUIInterfaceOrientationLandscapeLeft

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-27
      • 2016-10-26
      • 1970-01-01
      • 2011-03-21
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多