UIView 显示错误的方向
Posted
技术标签:
【中文标题】UIView 显示错误的方向【英文标题】:UIView shows wrong orientation 【发布时间】: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 [超级释放];【问题讨论】:
【参考方案1】:-
确保正确设置视图的委托。
您可能应该同时检查
UIInterfaceOrientationLandscapeRight
和UIInterfaceOrientationLandscapeLeft
。
【讨论】:
以上是关于UIView 显示错误的方向的主要内容,如果未能解决你的问题,请参考以下文章
UIScrollview 显示由核心数据属性组成的自定义 UIView:设计逻辑?